#include <ge_autoptr.h>
This class handles automatic deallocation of objects with
TYPE::Free()
. It is similar in function to
AutoAlloc
, but the object has to have been previously allocated.
公共成员函数 |
|
| AutoFree () | |
| AutoFree ( AutoFree &&src) | |
| AutoFree ( TYPE *p) | |
| ~AutoFree () | |
| void | Set ( TYPE *p) |
| operator TYPE * () const | |
| operator TYPE & () const | |
| TYPE * | operator-> () const |
| TYPE *const * | operator& () const |
| TYPE * | 发行 () |
| void | Free () |
| void | 赋值 ( TYPE *p) |
私有成员函数 |
|
| const AutoFree < TYPE > & | operator= (const AutoFree < TYPE > &p) |
| AutoFree (const AutoFree < TYPE > &p) | |
Private Attributes |
|
| TYPE * | ptr |
Friends |
|
| MAXON_ATTRIBUTE_FORCE_INLINE friend void | operator% (const AutoFree < TYPE > &alloc, maxon::ThreadReferencedError &err) |
|
private |
| AutoFree | ( | ) |
Default constructor.
| AutoFree | ( | AutoFree < TYPE > && | src | ) |
|
explicit |
Stores the pointer p internally.
| [in] | p |
A pointer to an object to be freed with
TYPE::Free(p)
。
AutoFree
instance takes over the ownership of the pointed object.
|
| ~ AutoFree | ( | ) |
Calls
TYPE::Free(ptr)
,其中
ptr
is the internally stored pointer.
|
private |
| void Set | ( | TYPE * | p | ) |
Sets p as the internal pointer.
| [in] | p |
A pointer to an object to be freed with
TYPE::Free(p)
。
AutoFree
instance takes over the ownership of the pointed object.
|
| operator TYPE * | ( | ) | const |
Conversion to a raw pointer to
TYPE
. Makes it possible to pass the object directly to functions like
Function(TYPE* t)
.
| operator TYPE & | ( | ) | const |
Conversion to a reference to
TYPE
. Makes it possible to pass the object directly to functions like
Function(TYPE& t)
.
| TYPE * operator-> | ( | ) | const |
Used for calls like
myauto->Function()
.
| TYPE * const* operator& | ( | ) | const |
Used for expressions like
&myauto
. Extracts a pointer to the internal pointer.
| TYPE * Release | ( | ) |
Retrieves the internal pointer and then sets it to nullptr . Thus the ownership is transfered to the caller.
| void Free | ( | ) |
Calls
TYPE::Free(ptr)
with the internal pointer and sets it to
nullptr
.
| void Assign | ( | TYPE * | p | ) |
Assigns p as the internal pointer.
| [in] | p |
A pointer to an object to be freed with
TYPE::Free(p)
。
AutoFree
instance takes over the ownership of the pointed object.
|
|
friend |
|
private |