libzypp
10.5.0
|
Assign a vaiable a certain value when going out of scope. More...
#include <DtorReset.h>
Classes | |
struct | Impl |
Requires _Val being copy constructible, and assignment _Var = _Val defined. More... | |
Public Member Functions | |
template<class _Var > | |
DtorReset (_Var &var_r) | |
template<class _Var , class _Val > | |
DtorReset (_Var &var_r, const _Val &val_r) | |
Private Attributes | |
shared_ptr< void > | _pimpl |
Assign a vaiable a certain value when going out of scope.
Use it e.g. to reset/cleanup in presence of exceptions.
struct Foo { void consume() { DtorReset x(_inConsume,false); _inConsume = true; MIL << _inConsume << endl; }; DefaultIntegral<bool,false> _inConsume; }; Foo f; MIL << f._inConsume << endl; // 0 f.consume(); // 1 MIL << f._inConsume << endl; // 0
Definition at line 49 of file DtorReset.h.
zypp::DtorReset::DtorReset | ( | _Var & | var_r | ) | [inline] |
Definition at line 53 of file DtorReset.h.
zypp::DtorReset::DtorReset | ( | _Var & | var_r, |
const _Val & | val_r | ||
) | [inline] |
Definition at line 57 of file DtorReset.h.
shared_ptr<void> zypp::DtorReset::_pimpl [private] |
Definition at line 76 of file DtorReset.h.