Regina Calculation Engine
|
A reference counted smart pointer that supports alternate models of ownership. More...
#include <utilities/safeptr.h>
Public Types | |
typedef T | element_type |
The pointee type. More... | |
Public Member Functions | |
SafePtr () | |
Constructs a new null pointer. More... | |
SafePtr (T *object) | |
Constructs a new safe pointer that points to the given object. More... | |
template<class Y > | |
SafePtr (const SafePtr< Y > &other) | |
Copy constructor. More... | |
T * | get () const |
Returns a raw pointer to the pointee, or null if the pointee has already been destroyed. More... | |
operator bool () const | |
Returns true if the pointee is non-null and has not yet been destroyed. More... | |
void | reset (T *object=0) |
Resets this to point to the given object. More... | |
SafePtr< T > & | operator= (const SafePtr< T > &)=delete |
Disable the default assignment operator. More... | |
A reference counted smart pointer that supports alternate models of ownership.
Specifically, there are two models of ownership for the pointee (of type T):
The pointee can indicate at runtime which model of ownership is in effect, through the return value of the function T::hasOwner().
The requirements for the pointee type T are as follows:
SafePointeeBase<T>
.bool hasOwner()
, which returns true
if and only if some other C++ object (which is not a SafePtr) owns the pointee.Destruction works as follows:
null
.false
.Under the hood, SafePtr uses SafeRemnant to achieve this.