libzypp  17.25.6
zypp::DtorReset Class Reference

Assign a vaiable a certain value when going out of scope. More...

#include <DtorReset.h>


struct  Impl
 Requires TVal being copy constructible, and assignment TVar = TVal defined. More...

Public Member Functions

 DtorReset ()
template<class TVar >
 DtorReset (TVar &var_r)
template<class TVar , class TVal >
 DtorReset (TVar &var_r, const TVal &val_r)

Private Attributes

shared_ptr< void > _pimpl

Detailed Description

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
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.

Constructor & Destructor Documentation

◆ DtorReset() [1/3]

zypp::DtorReset::DtorReset ( )

Definition at line 52 of file DtorReset.h.

◆ DtorReset() [2/3]

template<class TVar >
zypp::DtorReset::DtorReset ( TVar &  var_r)

Definition at line 55 of file DtorReset.h.

◆ DtorReset() [3/3]

template<class TVar , class TVal >
zypp::DtorReset::DtorReset ( TVar &  var_r,
const TVal &  val_r 

Definition at line 59 of file DtorReset.h.

Member Data Documentation

◆ _pimpl

shared_ptr<void> zypp::DtorReset::_pimpl

Definition at line 78 of file DtorReset.h.

The documentation for this class was generated from the following file:
#define MIL
Definition: Logger.h:79
Definition: DtorReset.h:52