diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2013-05-13 23:36:58 -0700 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2013-05-16 11:19:32 +0200 |
commit | fb83c468a8ba554e40bb5fbb746154fd1d6cd0c2 (patch) | |
tree | 1e96cb089b692fb50ed983e3568beda8d28b52c1 | |
parent | 0c5ba9355fcf84ea13bef2fe6c3dda8332083086 (diff) |
SmartPtr: add reset()
This mimics the behavior of boost smart pointers and is useful for
code where variables can be of either type, because "= NULL" is
not supported by our boost::intrusive_ptr wrapper.
-rw-r--r-- | src/syncevo/SmartPtr.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/syncevo/SmartPtr.h b/src/syncevo/SmartPtr.h index d0af9661..7f8c22dc 100644 --- a/src/syncevo/SmartPtr.h +++ b/src/syncevo/SmartPtr.h @@ -148,6 +148,10 @@ class SmartPtr m_pointer = pointer; } + void reset( T pointer = NULL ) { + set(pointer, NULL); + } + /** * transfer ownership over the pointer to caller and stop tracking it: * pointer tracked by smart pointer is set to NULL and the original @@ -178,6 +182,10 @@ template<class T, class base = T, class R = Unref > class eptr : base_t::set(pointer); return *this; } + + void reset(T *pointer = NULL) { + base_t::set(pointer); + } }; template <class T> class CxxUnref { |