libzypp 17.37.10

zypp::DtorReset Class Reference

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

`#include <zypp-core/base/dtorreset.h>`

Inheritance diagram for zypp::DtorReset:

## Classes
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
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition defaultintegral.h:42
zypp::DtorReset::DtorReset
DtorReset()
Definition dtorreset.h:52
MIL
#define MIL
Definition Logger.h:100

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.

## Constructor & Destructor Documentation

## ◆ DtorReset() [1/3]

zypp::DtorReset::DtorReset | ( |  | ) |
| inline

Definition at line 52 of file dtorreset.h.

## ◆ DtorReset() [2/3]

template<class TVar>

zypp::DtorReset::DtorReset | ( | TVar & | var_r | ) |
| inline

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 )
| inline

Definition at line 59 of file dtorreset.h.

## Member Data Documentation

## ◆ _pimpl

shared_ptr<void> zypp::DtorReset::_pimpl
| private

Definition at line 78 of file dtorreset.h.

The documentation for this class was generated from the following file:

- zypp-core/base/dtorreset.h