libzypp 17.31.23
dtorreset.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_CORE_BASE_DTORRESET_H
13#define ZYPP_CORE_BASE_DTORRESET_H
14
15#include <zypp-core/base/PtrTypes.h>
16
18namespace zypp
19{
20
22 //
23 // CLASS NAME : DtorReset
24 //
50 {
51 public:
53
54 template<class TVar>
55 DtorReset( TVar & var_r )
56 : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
57 {}
58 template<class TVar, class TVal>
59 DtorReset( TVar & var_r, const TVal & val_r )
60 : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
61 {}
62
63 private:
66 template<class TVar, class TVal>
67 struct Impl
68 {
69 Impl( TVar & var_r, const TVal & val_r )
70 : _var( var_r )
71 , _val( val_r )
72 {}
74 { _var = _val; }
75 TVar & _var;
76 TVal _val;
77 };
78 shared_ptr<void> _pimpl;
79 };
81
83} // namespace zypp
85#endif // ZYPP_CORE_BASE_DTORRESET_H
Assign a vaiable a certain value when going out of scope.
Definition: dtorreset.h:50
DtorReset(TVar &var_r, const TVal &val_r)
Definition: dtorreset.h:59
DtorReset(TVar &var_r)
Definition: dtorreset.h:55
shared_ptr< void > _pimpl
Definition: dtorreset.h:78
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Requires TVal being copy constructible, and assignment TVar = TVal defined.
Definition: dtorreset.h:68
Impl(TVar &var_r, const TVal &val_r)
Definition: dtorreset.h:69