nullptr.hh

Go to the documentation of this file.
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 typedef dune_nullptr_t nullptr_t;
00030 
00031 template<class T>
00032 bool operator == (T* t, dune_nullptr_t)
00033 {
00034     return (t == static_cast<T*>(nullptr));
00035 }
00036 
00037 template<class T>
00038 bool operator == (dune_nullptr_t, T* t)
00039 {
00040     return (t == static_cast<T*>(nullptr));
00041 }
00042 
00043 #endif // HAVE_NULLPTR
00044 
00045 #endif // DUNE_NULLPTR_HH

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].