#include <ncutMemory.h>
Public Types | |
typedef _Tp | element_type |
The pointed-to type. | |
Public Member Functions | |
greedy_ptr (element_type *__p=0) throw () | |
A greedy_ptr is usually constructed from a raw pointer. | |
greedy_ptr (element_type &__p) throw () | |
A greedy_ptr can be constructed from a reference. | |
greedy_ptr (const greedy_ptr &__a) throw () | |
A greedy_ptr can be constructed from another greedy_ptr. | |
template<typename _Tp1> | |
greedy_ptr (std::auto_ptr< _Tp1 > &__a) throw () | |
A greedy_ptr can be constructed from an auto_ptr. | |
greedy_ptr (std::auto_ptr< element_type > &__a) throw () | |
A greedy_ptr can be constructed from an auto_ptr. | |
template<typename _Tp1> | |
greedy_ptr (const greedy_ptr< _Tp1 > &__a) throw () | |
A greedy_ptr can be constructed from another greedy_ptr. | |
greedy_ptr & | operator= (const greedy_ptr &__a) throw () |
greedy_ptr assignment operator. | |
template<typename _Tp1> | |
greedy_ptr & | operator= (const greedy_ptr< _Tp1 > &__a) throw () |
greedy_ptr assignment operator. | |
greedy_ptr & | operator= (element_type *__p) throw () |
greedy_ptr assignment operator. | |
greedy_ptr & | operator= (element_type &__p) throw () |
greedy_ptr assignment operator. | |
~greedy_ptr () | |
element_type & | operator * () const throw () |
Smart pointer dereferencing. | |
element_type * | operator-> () const throw () |
Smart pointer dereferencing. | |
element_type * | get () const throw () |
Bypassing the smart pointer. | |
bool | owns () const throw () |
Getting ownership status. | |
element_type * | release () throw () |
Bypassing the smart pointer. | |
void | reset (element_type *__p=0) throw () |
Forcibly deletes the managed object. | |
void | reset (element_type &__p=0) throw () |
Forcibly deletes the managed object. | |
greedy_ptr (greedy_ptr_ref< element_type > __ref) throw () | |
Automatic conversions. | |
greedy_ptr & | operator= (greedy_ptr_ref< element_type > __ref) throw () |
template<typename _Tp1> | |
operator greedy_ptr_ref () throw () | |
template<typename _Tp1> | |
operator greedy_ptr () throw () |
A greedy_ptr
only owns the object it holds a pointer to, if it was constructed from a raw pointer (i.e. if it was the first greedy_ptr to manage the pointed-to object). Copying a greedy_ptr
copies the pointer but does not transfer ownership to the destination, the source greedy_ptr
retains ownership. If more than one greedy_ptr
owns the same object at the same time the behavior of the program is undefined.
|
A greedy_ptr is usually constructed from a raw pointer.
|
|
A greedy_ptr can be constructed from a reference.
|
|
A greedy_ptr can be constructed from another greedy_ptr.
|
|
A greedy_ptr can be constructed from an auto_ptr.
This object now owns the object previously owned by a, which has given up ownership. |
|
A greedy_ptr can be constructed from an auto_ptr.
|
|
A greedy_ptr can be constructed from another greedy_ptr.
This object does not own the object owned by a, which still holds ownership. |
|
When the greedy_ptr goes out of scope, the object it owns is deleted. If it no longer owns anything then this has no effect. The C++ standard says there is supposed to be an empty throw specification here, but omitting it is standard conforming. Its presence can be detected only if _Tp::~_Tp() throws, but this is prohibited. [17.4.3.6]/2 |
|
Automatic conversions. These operations convert an greedy_ptr into and from an greedy_ptr_ref automatically as needed. This allows constructs such as greedy_ptr<Derived> func_returning_greedy_ptr(.....); ... greedy_ptr<Base> ptr = func_returning_greedy_ptr(.....); |
|
Bypassing the smart pointer.
|
|
Smart pointer dereferencing. If this greedy_ptr is a null pointer, then this operation will crash. |
|
Smart pointer dereferencing. This returns the pointer itself, which the language then will automatically cause to be dereferenced. |
|
greedy_ptr assignment operator.
reset(__p) . |
|
greedy_ptr assignment operator.
reset(__p) . |
|
greedy_ptr assignment operator.
This object does not own the object owned by a, which still holds ownership. If this greedy_ptr used to own an object, that object has been deleted. |
|
greedy_ptr assignment operator.
|
|
Getting ownership status.
NULL pointers are never owned. |
|
Bypassing the smart pointer.
|
|
Forcibly deletes the managed object.
|
|
Forcibly deletes the managed object.
|