#include <stlsoft/util/null.hpp>
This class can act as a replacement for the NULL macro, by being validly assigned to or equated with pointer types only, as in
int i = NULL; // error int *p = NULL; // OK
if(i == NULL) {} // error if(NULL == i) {} // error
if(p == NULL) {} // OK if(NULL == p) {} // OK
When used via inclusion of the file stlsoft_nulldef.h, the macro NULL is redefined as NULL_v(), such that expressions containing NULL will be valid against pointers only.
Public Member Functions | |
NULL_v () | |
Default constructor. | |
template<typename T> | |
operator T * () const | |
Implicit conversion operator (convertible to any pointer type). | |
template<typename T2, typename C> | |
operator T2 C::* () const | |
Implicit conversion operator (convertible to any pointer type). | |
template<typename T> | |
bool | equal (T const &rhs) const |
Evaluates whether an instance of a type is null. | |
template<typename T> | |
bool | equals (T const &rhs) const |
Static Public Member Functions | |
static NULL_v | create () |
Static creation. |
NULL_v | ( | ) | [inline] |
operator T * | ( | ) | const [inline] |
Implicit conversion operator (convertible to any pointer type).
operator T2 C::* | ( | ) | const [inline] |
Implicit conversion operator (convertible to any pointer type).
bool equal | ( | T const & | rhs | ) | const [inline] |
Evaluates whether an instance of a type is null.
rhs | A reference arbitrary type which will be compared to null |
bool equals | ( | T const & | rhs | ) | const [inline] |