Assign a vaiable a certain value when going out of scope.
More...
#include <base/dtorreset.h>
|
struct | Impl |
| Requires TVal being copy constructible, and assignment TVar = TVal defined. More...
|
|
|
| DtorReset () |
|
template<class TVar > |
| DtorReset (TVar &var_r) |
|
template<class TVar , class TVal > |
| DtorReset (TVar &var_r, const TVal &val_r) |
|
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()
{
_inConsume = true;
MIL << _inConsume << endl;
};
};
Foo f;
MIL << f._inConsume << endl;
f.consume();
MIL << f._inConsume << endl;
Integral type with defined initial value when default constructed.
Assign a vaiable a certain value when going out of scope.
- Todo:
- Check if using call_traits enables 'DtorReset(std::string,"value")', as this currently would require assignment of 'char[]'.
Definition at line 49 of file dtorreset.h.
◆ DtorReset() [1/3]
zypp::DtorReset::DtorReset |
( |
| ) |
|
|
inline |
◆ DtorReset() [2/3]
template<class TVar >
zypp::DtorReset::DtorReset |
( |
TVar & |
var_r | ) |
|
|
inline |
◆ DtorReset() [3/3]
template<class TVar , class TVal >
zypp::DtorReset::DtorReset |
( |
TVar & |
var_r, |
|
|
const TVal & |
val_r |
|
) |
| |
|
inline |
◆ _pimpl
The documentation for this class was generated from the following file: