dune-common 2.1.1
|
00001 #ifndef DUNE_NULLPTR_HH 00002 #define DUNE_NULLPTR_HH 00003 00008 #if ! HAVE_NULLPTR 00009 00016 const // this is a const object... 00017 class dune_nullptr_t { // of type nullptr_t 00018 public: 00019 template<class T> // convertible to any type 00020 operator T*() const // of null non-member 00021 { return 0; } // pointer... 00022 template<class C, class T> // or any type of null 00023 operator T C::*() const // member pointer... 00024 { return 0; } 00025 private: 00026 void operator&() const; // whose address can't be taken 00027 } nullptr = {}; // and whose name is nullptr 00028 00029 namespace Dune { 00030 typedef dune_nullptr_t nullptr_t; 00031 } 00032 00033 template<class T> 00034 bool operator == (T* t, dune_nullptr_t) 00035 { 00036 return (t == static_cast<T*>(nullptr)); 00037 } 00038 00039 template<class T> 00040 bool operator == (dune_nullptr_t, T* t) 00041 { 00042 return (t == static_cast<T*>(nullptr)); 00043 } 00044 00045 #else 00046 00047 #include <cstddef> 00048 00049 namespace Dune { 00050 using std::nullptr_t; 00051 } 00052 00053 #endif // HAVE_NULLPTR 00054 00055 #endif // DUNE_NULLPTR_HH