libzypp: zypp-core/base/dtorreset.h Source File

libzypp 17.38.6

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 //
49 class DtorReset
50 {
51 public:
52 DtorReset() {}
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 {}
73 ~Impl()
74 { _var = _val; }
75 TVar & _var;
76 TVal _val;
77 };
78 shared_ptr<void> _pimpl;
79 };
80
81
83} // namespace zypp
85#endif // ZYPP_CORE_BASE_DTORRESET_H
PtrTypes.h
shared_ptr
zypp::DtorReset::DtorReset
DtorReset(TVar &var_r, const TVal &val_r)
Definition dtorreset.h:59
zypp::DtorReset::DtorReset
DtorReset(TVar &var_r)
Definition dtorreset.h:55
zypp::DtorReset::_pimpl
shared_ptr< void > _pimpl
Definition dtorreset.h:78
zypp::DtorReset::DtorReset
DtorReset()
Definition dtorreset.h:52
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::DtorReset::Impl
Requires TVal being copy constructible, and assignment TVar = TVal defined.
Definition dtorreset.h:68
zypp::DtorReset::Impl::_var
TVar & _var
Definition dtorreset.h:75
zypp::DtorReset::Impl::Impl
Impl(TVar &var_r, const TVal &val_r)
Definition dtorreset.h:69
zypp::DtorReset::Impl::~Impl
~Impl()
Definition dtorreset.h:73
zypp::DtorReset::Impl::_val
TVal _val
Definition dtorreset.h:76