![]() | InDesign SDK 20.5 |
#include <K2SmartPtr.h>

Public Types | |
| typedef T | element_type |
Public Member Functions | |
| scoped_ptr (T *p=0) | |
| ~scoped_ptr () | |
| void | reset (T *p=0) |
| T * | release () |
| T & | operator* () const |
| T * | operator-> () const |
| T * | get () const |
| bool | operator! () const |
| operator void * () const | |
Friends | |
| bool | operator== (const Self &lhs, const T *rhs) |
| bool | operator== (const T *lhs, const Self &rhs) |
| bool | operator!= (const Self &lhs, const T *rhs) |
| bool | operator!= (const T *lhs, const Self &rhs) |
scoped_ptr mimics a built-in pointer except that it guarantees deletion of the object pointed to, either on destruction of the scoped_ptr or via an explicit reset(). scoped_ptr is a simple solution for simple needs; see std::auto_ptr if your needs are more complex. Because scoped_ptr is simple, in its usual implementation every operation is as fast as for a built-in pointer and it has no more space overhead that a built-in pointer. scoped_ptr cannot be used in C++ Standard Library containers. Use a scoped_array if you need to manage a pointer to an array.
| inlineexplicit |
Constructs a scoped_ptr, storing a copy of p which MUST have been allocated using the operator new (or must be nil).
| p | [IN] - pointer to the resource that will transfer the ownership to this object. |
| inline |
Destroys the object pointed by stored pointer by calling the operator delete.
| inline |
Gets the stored pointer.
| inline |
De-reference operator. Behavior is undefined if the stored pointer is nil.
| inline |
Indirection operator. Behavior is undefined if the stored pointer is nil.
| inline |
Detaches from the stored pointer by transferring the ownership to the caller. Note: the signature of this method is error prone because it allows the caller to lose the resource by not assign it to anything.
| inline |
Destroys the object pointed by the stored pointer and then re-assigns it to the new value.