A helper class for defining pointers managed automatically with a limited garbage-collecting facility implemented over the functions of the Chusov::Memory namespace. More...
#include <chsvmem.h>
Public Types | |
typedef std::unique_ptr< element_type, DELETER > | MyBase |
A type of the inherited instance of the std::unique_ptr. | |
typedef C_auto_ptr< element_type, DELETER, pFree > | MyType |
A type of the current instantiation of the C_auto_ptr class. | |
typedef MyBase::pointer | pointer |
A type of the managed pointers. The same as the std::unique_ptr::pointer type. | |
Public Member Functions | |
C_auto_ptr (pointer pRight=pointer()) | |
Constructs an object of the C_auto_ptr template instance from the specified pointer that is to be managed by the constructed object. More... | |
C_auto_ptr (MyType &&rrRight) | |
A move constructor for the C_auto_ptr classes. The standard copy constructor is disallowed for the class (see std::unique_ptr::constructors). More... | |
MyType & | operator= (MyType &&rrRight) |
A move assignment operator for the C_auto_ptr classes. The standard copy assignment operator is disallowed for the class (see std::unique_ptr::operator=). More... | |
template<class Pointer > | |
Pointer | GetPtr () |
A helper wrapper function returning a pointer the object stores casting it to a type specified by a template parameter. | |
template<class Pointer > | |
const Pointer | GetPtr () const |
A helper wrapper function returning a pointer the object stores casting it to a type specified by a template parameter. | |
A helper class for defining pointers managed automatically with a limited garbage-collecting facility implemented over the functions of the Chusov::Memory namespace.
value_type | is a type of data the managed pointers will point to. The one can be void to manage generalized pointers. |
DELETER | is a type of a callable object used to free managed pointers at some point. It is the same type of objects as the std::unique_ptr::deleter_type. |
pFree | is an instance of the deleter object used to initialize the inherited instance of the std::unique_ptr. It is only used during the construction of the object. It means that the actual deleter used by an instance of the C_auto_ptr may differ from the one defined in the template parameters list. |
Although the class template is defined rather generally it is aimed to perform memory managing functions using the functions of the Chusov::Memory namespace such as AllocateData.
The class template is implemented as the inheritor of the standard std::unique_ptr class template providing the methods of the one. The template provides minimum changes to the standard interface, including defining constructors, a move assignment operator and a pair of methods defined as a wrappers over the reinterpret_cast operator to improve readability of the client code working with generalized pointers of the void* type. Also the template is defined so that an instance of a deleter object, specified as an argument of the std::unique_ptr constructors, is defined a template argument for this type. This is done to minimize code necessary to be written to implement auto-pointer objects employing the functions of the Chusov::Memory namespace. If it is necessary to use dynamically specified deleter objects the one can use the standard std::unique_ptr class template without any loss of functionality.