C12Adapter Opensource C++ Interface
|
Class that helps preserve a certain value of a variable outside a local C++ scope. More...
Public Member Functions | |
MValueSavior (Type *var) | |
Constructor of the savior that accepts the pointer to the variable which value has to be saved. More... | |
MValueSavior (Type *var, const Type &scopeValue) | |
Constructor of the savior that accepts the pointer to the value that has to be saved, and a new value. More... | |
~MValueSavior () | |
Destructor that restores the variable given in constructor to its original value. 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. | |
Class that helps preserve a certain value of a variable outside a local C++ scope.
The constructor saves the given value, and the destructor restores it. The type of the variable to manipulate shall be assignable, or a compile error will result from the usage attempt. Typical use case:
|
inline |
Constructor of the savior that accepts the pointer to the variable which value has to be saved.
The constructor will store the address of the variable and its value, so it can be restored in the destructor.
var | Pointer to the value that has to be saved through the time of existence of the value savior class. |
|
inline |
Constructor of the savior that accepts the pointer to the value that has to be saved, and a new value.
The constructor will store the address of the value and the value itself, so it can be restored in the destructor. Then it will assign a new value given as parameter. This constructor is a convenient shortcut of the following:
which can be written in a new line:
var | Pointer to the value that has to be saved through the time of existence of the value savior class. |
scopeValue | New value with which the given variable will be initialized within this constructor. |
|
inline |
Destructor that restores the variable given in constructor to its original value.
As value savior is often created on the stack, there is no necessity to call its destructor directly or by means of operator
delete
.