#include <libmesh_nullptr.h>
Public Member Functions | |
template<class T > | |
operator T * () const | |
template<class C , class T > | |
operator T C::* () const | |
Private Member Functions | |
void | operator& () const |
A C++03-compatible nullptr type implemented as a library solution rather than a language keyword. Originally due to Scott Meyers, Effective C++, 2nd Edition, Item 25. The main benefits of using this type over NULL are 1.) Expressiveness: 2.) Disambiguating overloads, e.g. void f(int); void f(double *); f(NULL); // ambiguous f(nullptr); // unambiguous - calls the version of f taking a pointer
We are specifically not attempting to redefine the 'nullptr' keyword itself – that can lead to issues when C++11 is disabled, yet the compiler still has 'nullptr' defined. Therefore, client code that wishes to be more expressive/correct should use 'libmesh_nullptr' for maximum backwards compatibility.
Code originally coped from: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr#Solution_and_Sample_Code
Definition at line 53 of file libmesh_nullptr.h.
|
inline |
Definition at line 58 of file libmesh_nullptr.h.
|
inline |
Definition at line 62 of file libmesh_nullptr.h.
References libmesh_nullptr, and operator&().
|
private |
Referenced by operator T C::*().