dune-common  2.2.0
nullptr.hh
Go to the documentation of this file.
1 #ifndef DUNE_NULLPTR_HH
2 #define DUNE_NULLPTR_HH
3 
8 #if ! HAVE_NULLPTR
9 
16 const // this is a const object...
17 class dune_nullptr_t { // of type nullptr_t
18 public:
19  template<class T> // convertible to any type
20  operator T*() const // of null non-member
21  { return 0; } // pointer...
22  template<class C, class T> // or any type of null
23  operator T C::*() const // member pointer...
24  { return 0; }
25 private:
26  void operator&() const; // whose address can't be taken
27 } nullptr = {}; // and whose name is nullptr
28 
29 namespace Dune {
31 }
32 
33 template<class T>
35 {
36  return (t == static_cast<T*>(nullptr));
37 }
38 
39 template<class T>
41 {
42  return (t == static_cast<T*>(nullptr));
43 }
44 
45 #else
46 
47 #include <cstddef>
48 
49 namespace Dune {
50  using std::nullptr_t;
51 }
52 
53 #endif // HAVE_NULLPTR
54 
55 #endif // DUNE_NULLPTR_HH