#include <CheckedPtr.hh>
Its role is to check for the nullness of the pointer it contains before a dereference operation. It is used by Owned<T*> and BLink<T> when they return their pointer, so that the assertion can be done only if the pointer is dereferenced rather than just used by value (in a boolean test or comparison to other pointer etc). For instance,
Owned<Foo*> foo; if ( isNull(foo()) ) doSomething(); // line 1 foo()->callFooMethod(); // line 2
CheckedPtr can be used as a normal pointer for almost any pointer operation. The only known case where this is not true is when giving a CheckedPtr<T> to a function template expecting a T*, since the compiler does not attempt any conversion in this case, and you must use (T*) in front of your argument.
Definition at line 59 of file CheckedPtr.hh.
Public Methods | |
CheckedPtr (T *ptr) | |
Construct for ptr. | |
CheckedPtr (const CheckedPtr &rhs) | |
Copy consructor. | |
template<typename T2> | CheckedPtr (const CheckedPtr< T2 > &rhs) |
Copy-convert constructor for pointer conversions. | |
T * | operator-> () const |
dereference for access | |
T & | operator * () const |
dereference for use | |
operator T * () const | |
Convert to a pointer of type T when necessary. | |
Comparison operators | |
Friends | |
class | CheckedPtr |
All CheckedPtr are friends so pointer conversions possible. |