![]() |
Safe C++ NULL pointer implementation.This implementation offers a remedy for the use of the NULL pointer in C++. For this, the NULL macro is replaced by an instance of the Null class, which can only be assigned and compared with pointers and pointers-to-member. Therefore the use of NULL regains the type safety it lost in C++ due to the strict C++ type system.
The NULL pointer is used exactly as before:
More...
#include <Null.h>
Public Member Functions | |
Constructor | |
Null () | |
The default constructor of the Null class. | |
Conversion operators | |
template<typename T > | |
operator T * () const | |
Conversion operator to a pointer. More... | |
template<typename T , typename C > | |
operator T C::* () const | |
Conversion operator to a pointer-to-member. More... | |
Utility functions | |
template<typename T > | |
bool | equal (const T *rhs) const |
Comparison between Null and a pointer. More... | |
template<typename T , typename C > | |
bool | equal (const T C::*rhs) const |
Comparison between Null and a pointer-to-member. More... | |
Private Member Functions | |
Forbidden operations | |
Null (const Null &n) | |
Copy constructor (private & undefined) | |
Null & | operator= (const Null &n) |
Copy assignment operator (private & undefined) | |
void * | operator& () const |
Address operator (private & undefined) | |
Safe C++ NULL pointer implementation.
This implementation offers a remedy for the use of the NULL pointer in C++. For this, the NULL macro is replaced by an instance of the Null class, which can only be assigned and compared with pointers and pointers-to-member. Therefore the use of NULL regains the type safety it lost in C++ due to the strict C++ type system.
The NULL pointer is used exactly as before:
|
inline |
Comparison between Null and a pointer.
The function offers a type safe comparison between zero and an arbitrary pointer.
|
inline |
Comparison between Null and a pointer-to-member.
The function offers a type safe comparison between zero and an arbitrary pointer-to-member.
|
inline |
Conversion operator to a pointer.
This conversion operator offers a type safe conversion of zero to a pointer of any kind.
|
inline |
Conversion operator to a pointer-to-member.
This conversion operator offers the type safe conversion of zero to a pointer-to-member of any kind.