00001 #ifndef COMMONS_NULLPTR_H 00002 #define COMMONS_NULLPTR_H 00003 00004 // From <http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr> 00005 00006 namespace commons 00007 { 00008 00009 const // It is a const object... 00010 class nullptr_t 00011 { 00012 public: 00013 template<class T> 00014 operator T*() const // convertible to any type of null non-member pointer... 00015 { return 0; } 00016 00017 template<class C, class T> 00018 operator T C::*() const // or any type of null member pointer... 00019 { return 0; } 00020 00021 private: 00022 void operator&() const; // Can't take address of nullptr 00023 00024 } nullptr = {}; 00025 00026 } 00027 00028 #endif