DtorReset.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_BASE_DTORRESET_H
00013 #define ZYPP_BASE_DTORRESET_H
00014
00015 #include "zypp/base/PtrTypes.h"
00016
00018 namespace zypp
00019 {
00020
00022
00023
00024
00049 class DtorReset
00050 {
00051 public:
00052 template<class _Var>
00053 DtorReset( _Var & var_r )
00054 : _pimpl( new Impl<_Var,_Var>( var_r, var_r ) )
00055 {}
00056 template<class _Var, class _Val>
00057 DtorReset( _Var & var_r, const _Val & val_r )
00058 : _pimpl( new Impl<_Var,_Val>( var_r, val_r ) )
00059 {}
00060
00061 private:
00064 template<class _Var, class _Val>
00065 struct Impl
00066 {
00067 Impl( _Var & var_r, const _Val & val_r )
00068 : _var( var_r )
00069 , _val( val_r )
00070 {}
00071 ~Impl()
00072 { _var = _val; }
00073 _Var & _var;
00074 _Val _val;
00075 };
00076 shared_ptr<void> _pimpl;
00077 };
00079
00081 }
00083 #endif // ZYPP_BASE_DTORRESET_H