NullPtr.h 896 B

12345678910111213141516171819202122232425262728293031
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /* Implements a mozilla::IsNullPointer<T> type trait. */
  6. #ifndef mozilla_NullPtr_h
  7. #define mozilla_NullPtr_h
  8. #include "mozilla/TypeTraits.h"
  9. namespace mozilla {
  10. /**
  11. * IsNullPointer<T>::value is true iff T is decltype(nullptr).
  12. *
  13. * Ideally this would be in TypeTraits.h, but C++11 omitted std::is_null_pointer
  14. * (fixed in C++14), so in the interests of easing a switch to <type_traits>,
  15. * this trait lives elsewhere.
  16. */
  17. template<typename T>
  18. struct IsNullPointer : FalseType {};
  19. template<>
  20. struct IsNullPointer<decltype(nullptr)> : TrueType {};
  21. } // namespace mozilla
  22. #endif /* mozilla_NullPtr_h */