libzypp  15.28.6
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  template<class TVar>
53  DtorReset( TVar & var_r )
54  : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
55  {}
56  template<class TVar, class TVal>
57  DtorReset( TVar & var_r, const TVal & val_r )
58  : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
59  {}
60 
61  private:
64  template<class TVar, class TVal>
65  struct Impl
66  {
67  Impl( TVar & var_r, const TVal & val_r )
68  : _var( var_r )
69  , _val( val_r )
70  {}
72  { _var = _val; }
73  TVar & _var;
74  TVal _val;
75  };
76  shared_ptr<void> _pimpl;
77  };
79 
81 } // namespace zypp
83 #endif // ZYPP_BASE_DTORRESET_H
DtorReset(TVar &var_r)
Definition: DtorReset.h:53
Requires TVal being copy constructible, and assignment TVar = TVal defined.
Definition: DtorReset.h:65
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:57
Impl(TVar &var_r, const TVal &val_r)
Definition: DtorReset.h:67
shared_ptr< void > _pimpl
Definition: DtorReset.h:76