2013-07-24 00:41:39 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-09-01 13:16:17 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-01-14 09:09:11 -08:00
|
|
|
/* Implements a mozilla::IsNullPointer<T> type trait. */
|
2012-09-01 13:16:17 -07:00
|
|
|
|
2013-07-24 00:41:39 -07:00
|
|
|
#ifndef mozilla_NullPtr_h
|
|
|
|
#define mozilla_NullPtr_h
|
2012-09-01 13:16:17 -07:00
|
|
|
|
2015-01-14 09:09:11 -08:00
|
|
|
#include "mozilla/TypeTraits.h"
|
2012-09-01 13:16:17 -07:00
|
|
|
|
2014-01-02 15:27:41 -08:00
|
|
|
namespace mozilla {
|
|
|
|
|
2012-09-01 13:16:17 -07:00
|
|
|
/**
|
2015-01-14 09:09:11 -08:00
|
|
|
* IsNullPointer<T>::value is true iff T is decltype(nullptr).
|
2014-01-02 15:27:41 -08:00
|
|
|
*
|
|
|
|
* Ideally this would be in TypeTraits.h, but C++11 omitted std::is_null_pointer
|
2015-01-14 09:09:11 -08:00
|
|
|
* (fixed in C++14), so in the interests of easing a switch to <type_traits>,
|
2014-01-02 15:27:41 -08:00
|
|
|
* this trait lives elsewhere.
|
2012-09-01 13:16:17 -07:00
|
|
|
*/
|
2014-01-02 15:27:41 -08:00
|
|
|
template<typename T>
|
2015-01-14 09:09:11 -08:00
|
|
|
struct IsNullPointer : FalseType {};
|
2014-01-02 15:27:41 -08:00
|
|
|
|
2014-06-12 23:34:08 -07:00
|
|
|
template<>
|
2015-01-14 09:09:11 -08:00
|
|
|
struct IsNullPointer<decltype(nullptr)> : TrueType {};
|
|
|
|
|
2014-06-12 23:34:08 -07:00
|
|
|
}
|
2012-09-01 13:16:17 -07:00
|
|
|
|
2013-07-24 00:41:39 -07:00
|
|
|
#endif /* mozilla_NullPtr_h */
|