libzypp: zypp::DtorReset Class Reference

libzypp 17.25.10

Classes | Public Member Functions | Private Attributes | List of all members
zypp::DtorReset Class Reference
RAII solutions

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

`#include <DtorReset.h>`

## 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
MIL
#define MIL
Definition: Logger.h:91
zypp::DtorReset::DtorReset
DtorReset()
Definition: DtorReset.h:52

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/base/DtorReset.h