Dune Core Modules (2.4.1)

nullptr.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_NULLPTR_HH
4#define DUNE_NULLPTR_HH
5
10#if ! HAVE_NULLPTR
11
18const // this is a const object...
19class dune_nullptr_t { // of type nullptr_t
20public:
21 template<class T> // convertible to any type
22 operator T*() const // of null non-member
23 { return 0; } // pointer...
24 template<class C, class T> // or any type of null
25 operator T C::*() const // member pointer...
26 { return 0; }
27private:
28 void operator&() const; // whose address can't be taken
29} nullptr = {}; // and whose name is nullptr
30
31namespace Dune {
32 typedef dune_nullptr_t nullptr_t;
33}
34
35template<class T>
36bool operator == (T* t, dune_nullptr_t)
37{
38 return (t == static_cast<T*>(nullptr));
39}
40
41template<class T>
42bool operator == (dune_nullptr_t, T* t)
43{
44 return (t == static_cast<T*>(nullptr));
45}
46
47#else
48
49#include <cstddef>
50
51namespace Dune {
52 using std::nullptr_t;
53}
54
55#endif // HAVE_NULLPTR
56
57#endif // DUNE_NULLPTR_HH
Fallback implementation of nullptr.
Definition: nullptr.hh:19
Dune namespace.
Definition: alignment.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)