nullptr.hh

Go to the documentation of this file.
00001 #ifndef DUNE_NULLPTR_HH
00002 #define DUNE_NULLPTR_HH
00003 
00004 #if ! HAVE_NULLPTR
00005 
00012 const                        // this is a const object...
00013 class dune_nullptr_t {            // of type nullptr_t
00014 public:
00015   template<class T>          // convertible to any type
00016     operator T*() const      // of null non-member
00017     { return 0; }            // pointer...
00018   template<class C, class T> // or any type of null
00019     operator T C::*() const  // member pointer...
00020     { return 0; }
00021 private:
00022   void operator&() const;    // whose address can't be taken
00023 } nullptr = {};              // and whose name is nullptr
00024 
00025 typedef dune_nullptr_t nullptr_t;
00026 
00027 template<class T>
00028 bool operator == (T* t, dune_nullptr_t)
00029 {
00030     return (t == static_cast<T*>(nullptr));
00031 }
00032 
00033 template<class T>
00034 bool operator == (dune_nullptr_t, T* t)
00035 {
00036     return (t == static_cast<T*>(nullptr));
00037 }
00038 
00039 #endif // HAVE_NULLPTR
00040 
00041 #endif // DUNE_NULLPTR_HH
Generated on Mon Apr 26 10:45:21 2010 for dune-common by  doxygen 1.6.3