Inheritance diagram for code::InitDerivedSmartPtr< BaseType, DerivedType >:
Public Member Functions | |
InitDerivedSmartPtr (DerivedType *p) | |
Think of a DerivedSmartPtr as holding a pointer to DerivedType, i.e. | |
InitDerivedSmartPtr (InitSmartPtr< DerivedType > orig) | |
Think of a DerivedSmartPtr as holding a pointer to DerivedType, i.e. | |
InitDerivedSmartPtr () | |
Default initialization creates a new object. | |
InitSmartPtr< DerivedType > | getDerivedType () |
To obtain a derived object pointer. | |
bool | operator< (const InitDerivedSmartPtr< BaseType, DerivedType > &other) const |
To enable easy mapping of SmartPtrs to STL containers, we overload the < operator. | |
DerivedType & | operator * () const |
Like a regular pointer; an InitSmartPtr is always valid, no assertions are done. | |
DerivedType * | operator-> () const |
Like a regular pointer; an InitSmartPtr is always valid, no assertions are done. | |
bool | is_ptr_valid () const |
InitSmartPointers are always valid. | |
bool | operator< (const InitSmartPtr< BaseType > &other) const |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the < operator is overloaded to compare the objects being pointed to. | |
bool | operator< (const SmartPtr< BaseType > &other) const |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the < operator is overloaded to compare the objects being pointed to. | |
bool | is_stored_before (const InitSmartPtr< BaseType > &other) const |
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances. | |
bool | is_stored_before (const SmartPtr< BaseType > &other) const |
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances. | |
bool | is_unique () const |
Is the pointed-to-object unique? | |
int | copies () const |
Returns number of references to this SmartPtr. | |
SmartPtr< const BaseType > | const_ptr () const |
Will return a reference-counted pointer to const X, so that functions that promise not to change the object can ask for, and receive, SmartPtr<const X>. | |
bool | operator== (const SmartPtr< BaseType > &other) const |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the == operator is overloaded to compare the objects being pointed to. | |
SmartPtr< D > | recast () |
Recast this SmartPtr to the desired type. | |
SmartPtr< const D > | recast () const |
Public Attributes | |
BaseType * | ptr |
Internal pointer storage. | |
int * | numCopies |
Internal number of copies storage. |
code::InitDerivedSmartPtr< BaseType, DerivedType >::InitDerivedSmartPtr | ( | DerivedType * | p | ) | [inline] |
Think of a DerivedSmartPtr as holding a pointer to DerivedType, i.e.
as a InitSmartPtr< DerivedType >
A DerivedType* is a BaseType* also.
It is implemented as a subclass of BaseType to make virtual overloading possible.
code::InitDerivedSmartPtr< BaseType, DerivedType >::InitDerivedSmartPtr | ( | InitSmartPtr< DerivedType > | orig | ) | [inline] |
Think of a DerivedSmartPtr as holding a pointer to DerivedType, i.e.
as a InitSmartPtr< DerivedType >
A DerivedType* is a BaseType* also.
It is implemented as a subclass of BaseType to make virtual overloading possible.
code::InitDerivedSmartPtr< BaseType, DerivedType >::InitDerivedSmartPtr | ( | ) | [inline] |
Default initialization creates a new object.
A default constructor is necessary.
SmartPtr<const BaseType > code::SmartPtr< BaseType >::const_ptr | ( | ) | const [inline, inherited] |
Will return a reference-counted pointer to const X, so that functions that promise not to change the object can ask for, and receive, SmartPtr<const X>.
int code::SmartPtr< BaseType >::copies | ( | ) | const [inline, inherited] |
Returns number of references to this SmartPtr.
InitSmartPtr< DerivedType > code::InitDerivedSmartPtr< BaseType, DerivedType >::getDerivedType | ( | ) | [inline] |
To obtain a derived object pointer.
This is faster than keeping around the DerivedSmartPtr object.
bool code::InitSmartPtr< BaseType >::is_ptr_valid | ( | ) | const [inline, inherited] |
bool code::SmartPtr< BaseType >::is_stored_before | ( | const SmartPtr< BaseType > & | other | ) | const [inline, inherited] |
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances.
In that case, pointers need to be compared using is_stored_before()
When the objects themselves are ordered, you should be using the < operator.
bool code::InitSmartPtr< BaseType >::is_stored_before | ( | const InitSmartPtr< BaseType > & | other | ) | const [inline, inherited] |
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances.
In that case, pointers need to be compared using is_stored_before()
When the objects themselves are ordered, you should be using the < operator.
bool code::SmartPtr< BaseType >::is_unique | ( | ) | const [inline, inherited] |
Is the pointed-to-object unique?
You can use this function to determine whether there is anybody else holding references to this object.
DerivedType& code::InitDerivedSmartPtr< BaseType, DerivedType >::operator * | ( | ) | const [inline] |
Like a regular pointer; an InitSmartPtr is always valid, no assertions are done.
Reimplemented from code::InitSmartPtr< BaseType >.
DerivedType* code::InitDerivedSmartPtr< BaseType, DerivedType >::operator-> | ( | ) | const [inline] |
Like a regular pointer; an InitSmartPtr is always valid, no assertions are done.
Reimplemented from code::InitSmartPtr< BaseType >.
bool code::SmartPtr< BaseType >::operator< | ( | const SmartPtr< BaseType > & | other | ) | const [inline, inherited] |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the < operator is overloaded to compare the objects being pointed to.
Hence, for this to be usable, the class X should have a < operator defined.
The behavior of the < and == operators is as follows:
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances. In that case, pointers need to be compared. Use is_stored_before()
bool code::InitSmartPtr< BaseType >::operator< | ( | const InitSmartPtr< BaseType > & | other | ) | const [inline, inherited] |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the < operator is overloaded to compare the objects being pointed to.
Hence, for this to be usable, the class X should have a < operator defined.
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances. In that case, pointers need to be compared. Use is_stored_before()
bool code::InitDerivedSmartPtr< BaseType, DerivedType >::operator< | ( | const InitDerivedSmartPtr< BaseType, DerivedType > & | other | ) | const [inline] |
To enable easy mapping of SmartPtrs to STL containers, we overload the < operator.
The meaning of < is to compare the objects being pointed to. Hence, for this to be usable, the class X should have a < operator defined.
bool code::SmartPtr< BaseType >::operator== | ( | const SmartPtr< BaseType > & | other | ) | const [inline, inherited] |
To enable easy mapping of SmartPtrs of ordered objects to STL containers, the == operator is overloaded to compare the objects being pointed to.
Hence, for this to be usable, the class X should have a == operator defined.
The behavior of the < and == operators is as follows:
In some cases, it makes no sense for the objects themselves to be ordered; yet, you might want simply unique instances. In that case, pointers need to be compared. Use is_stored_before()
SmartPtr<const D> code::SmartPtr< BaseType >::recast | ( | ) | const [inline, inherited] |
SmartPtr<D> code::SmartPtr< BaseType >::recast | ( | ) | [inline, inherited] |
Recast this SmartPtr to the desired type.
An empty SmartPtr is returned if type conversion fails.
class A { ... }; class B: public A { ... }; class C: public B { ... }; class Unrelated { ... };
SmartPtr b = new C (); SmartPtr a = b.recast<A>(); // upcast SmartPtr<C> c = b.recast<C>(); // downcast assert (a.copies() == 3);
SmartPtr<Unrelated> u = b.recast<Unrelated>(); assert (!u.is_ptr_valid()); assert (a.copies() == 3);
int* code::SmartPtr< BaseType >::numCopies [inherited] |
Internal number of copies storage.
DerivedSmartPtr has access.
BaseType * code::SmartPtr< BaseType >::ptr [inherited] |
Internal pointer storage.
DerivedSmartPtr has access.