Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set | ||
|
||
#include <scoped_ptr.h>
Public Types | |
typedef C | element_type |
The element type. | |
Public Member Functions | |
scoped_ptr (C *p=NULL) | |
Constructor. | |
~scoped_ptr () | |
Destructor. | |
void | reset (C *p=NULL) |
Reset. | |
C & | operator* () const |
Accessors to get the owned object. | |
C * | operator-> () const |
C * | get () const |
bool | operator== (C *p) const |
Comparison operators. | |
bool | operator!= (C *p) const |
void | swap (scoped_ptr &p2) |
Swap two scoped pointers. | |
C * | release () |
Release a pointer. | |
Friends | |
scoped_ptr< C > | make_scoped_ptr (C *p) |
friend class that can access copy ctor (although if it actually calls a copy ctor, there will be a problem) see below |
That is, scoped_ptr<T> owns the T object that it points to. Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
The size of a scoped_ptr is small: sizeof(scoped_ptr<C>) == sizeof(C*)
Definition at line 47 of file scoped_ptr.h.
typedef C operations_research::scoped_ptr< C >::element_type |
operations_research::scoped_ptr< C >::scoped_ptr | ( | C * | p = NULL |
) | [inline, explicit] |
Constructor.
Defaults to intializing with NULL. There is no way to create an uninitialized scoped_ptr. The input parameter must be allocated with new.
Definition at line 56 of file scoped_ptr.h.
operations_research::scoped_ptr< C >::~scoped_ptr | ( | ) | [inline] |
Destructor.
If there is a C object, delete it. We don't need to test ptr_ == NULL because C++ does that for us.
Definition at line 60 of file scoped_ptr.h.
void operations_research::scoped_ptr< C >::reset | ( | C * | p = NULL |
) | [inline] |
Reset.
Deletes the current owned object, if any. Then takes ownership of a new object, if given. this->reset(this->get()) works.
Definition at line 68 of file scoped_ptr.h.
C& operations_research::scoped_ptr< C >::operator* | ( | ) | const [inline] |
Accessors to get the owned object.
operator* and operator-> will assert() if there is no current object.
Definition at line 78 of file scoped_ptr.h.
C* operations_research::scoped_ptr< C >::operator-> | ( | ) | const [inline] |
Definition at line 82 of file scoped_ptr.h.
C* operations_research::scoped_ptr< C >::get | ( | ) | const [inline] |
Definition at line 86 of file scoped_ptr.h.
bool operations_research::scoped_ptr< C >::operator== | ( | C * | p | ) | const [inline] |
Comparison operators.
These return whether two scoped_ptr refer to the same object, not just to two different but equal objects.
Definition at line 91 of file scoped_ptr.h.
bool operations_research::scoped_ptr< C >::operator!= | ( | C * | p | ) | const [inline] |
Definition at line 92 of file scoped_ptr.h.
void operations_research::scoped_ptr< C >::swap | ( | scoped_ptr< C > & | p2 | ) | [inline] |
C* operations_research::scoped_ptr< C >::release | ( | ) | [inline] |
Release a pointer.
The return value is the current pointer held by this object. If this object holds a NULL pointer, the return value is NULL. After this operation, this object will hold a NULL pointer, and will not own the object any more.
Definition at line 106 of file scoped_ptr.h.
scoped_ptr<C> make_scoped_ptr | ( | C * | p | ) | [friend] |
friend class that can access copy ctor (although if it actually calls a copy ctor, there will be a problem) see below