C12Adapter Opensource C++ Interface
|
Compiler version independent unique pointer to a variable that is not an array. More...
Public Member Functions | |
MUniquePtr (Type *ptr=NULL) | |
Explicit initialization constructor. More... | |
~MUniquePtr () | |
Destructor. More... | |
void | reset (Type *ptr=NULL) |
Destroy the current object and assign a given pointer. More... | |
![]() | |
Type * | operator-> () const |
Field dereference operator. | |
Type & | operator* () const |
Pointer dereference operator. | |
Type * | get () const |
Get the underlying pointer. | |
Type * | release () |
Return the the underlying pointer while nullifying the unique pointer object. | |
Additional Inherited Members | |
![]() | |
typedef Type | element_type |
Type of the unique pointer. | |
![]() | |
MGenericNoncopyablePtr (Type *ptr=NULL) | |
Protected explicit initialization constructor. | |
~MGenericNoncopyablePtr () | |
Protected destructor. More... | |
![]() | |
Type * | m_pointer |
Pointer to object. | |
Compiler version independent unique pointer to a variable that is not an array.
This one avoids a problem with older compilers that do not support unique_ptr, while at the same time silences deprecation warnings of newer compilers such as GNU GCC 6.1.1 or later.
The class interface is a proper subset of classic auto_ptr, however it does not have a copy constructor at all, making it safe in the way unique_ptr is safe. The whole codebase can be moved to using unique_ptr once all the clients of the library upgrade their compilers from C++Builder 2007 and Visual C++ 2010.
One cannot give an array to unique pointer, and there is a static check for explicit array type. Notice, it is still possible to use the class improperly if a given pointer is not an array, but it points to an array.
|
inlineexplicit |
Explicit initialization constructor.
Usage is compatible with both std::auto_ptr and std::unique_ptr
|
inline |
Destructor.
Same as std::auto_ptr, and different from std::unique_ptr as it cannot handle arrays correctly. There is a compile time check that verifies the pointer is not declared as array.
|
inline |
Destroy the current object and assign a given pointer.
Usage is compatible with both std::auto_ptr and std::unique_ptr