libzypp  13.10.6
zypp::DtorReset Class Reference

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
 

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

template<class _Var >
zypp::DtorReset::DtorReset ( _Var &  var_r)
inline

Definition at line 53 of file DtorReset.h.

template<class _Var , class _Val >
zypp::DtorReset::DtorReset ( _Var &  var_r,
const _Val &  val_r 
)
inline

Definition at line 57 of file DtorReset.h.

Member Data Documentation

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

Definition at line 76 of file DtorReset.h.


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