AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface

◆ ScopeGuard() [2/2]

template<typename T >
drama::ScopeGuard< T >::ScopeGuard ( T &  item,
const executionVal,
const exitVal 
)
inline

Construct a ScopeGuard for the specified item.

It is set to the "executionVal" value at this point. When the destructor is invoked, it is set to the specified exitVal value.

Note
The value in the item is not protected during the existence of this object. It is set to executionVal when this object is constructed and set back to its initial value when the object is destroyed, but nothing prevents it being changed while the object exists, and in that case, the changed value is overwritten when this object is destroyed.
Parameters
itemThe item to be guarded.
executionValThe value that should be placed in the item when this constructed is executed.
exitValThe value to be put in the item when this object is destroyed.

References drama::CreateRunDramaTask().