From bc4335c356dc3e9beaa2ed3631ee2831a59a9523 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Sat, 1 Nov 2014 15:26:34 +0000 Subject: [PATCH] Added conditional compilation Added conditional compilation. Changed namespace from etl to std. --- nullptr.h | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/nullptr.h b/nullptr.h index c868f4d6..6e9b37e9 100644 --- a/nullptr.h +++ b/nullptr.h @@ -33,7 +33,8 @@ SOFTWARE. /// A definition of nullptr for compilers that don't support it as standard. ///\ingroup utilities -namespace etl +#if defined(_MSC_VER) && (_MSC_VER < 1600) +namespace std { //***************************************************************************** /// A null pointer type. @@ -70,5 +71,40 @@ namespace etl const nullptr_t nullptr = {}; } +//***************************************************************************** +/// A null pointer type. +///\ingroup nullptr +//***************************************************************************** +class nullptr_t +{ +public: + + // Convertible to any type of null non-member pointer. + template + inline operator T*() const + { + return 0; + } + + // Or any type of null member pointer. + template + inline operator T C::*() const + { + return 0; + } + +private: + + // Can't take address of nullptr. + void operator&() const; +}; + +//***************************************************************************** +/// A null pointer. +///\ingroup nullptr +//***************************************************************************** +const nullptr_t nullptr = {}; + +#endif #endif