libzypp  16.22.5
DtorReset.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_DTORRESET_H
13 #define ZYPP_BASE_DTORRESET_H
14 
15 #include "zypp/base/PtrTypes.h"
16 
18 namespace 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  {}
74  { _var = _val; }
75  TVar & _var;
76  TVal _val;
77  };
78  shared_ptr<void> _pimpl;
79  };
81 
83 } // namespace zypp
85 #endif // ZYPP_BASE_DTORRESET_H
DtorReset(TVar &var_r)
Definition: DtorReset.h:55
Requires TVal being copy constructible, and assignment TVar = TVal defined.
Definition: DtorReset.h:67
Assign a vaiable a certain value when going out of scope.
Definition: DtorReset.h:49
DtorReset(TVar &var_r, const TVal &val_r)
Definition: DtorReset.h:59
Impl(TVar &var_r, const TVal &val_r)
Definition: DtorReset.h:69
shared_ptr< void > _pimpl
Definition: DtorReset.h:78