From fb83c468a8ba554e40bb5fbb746154fd1d6cd0c2 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 13 May 2013 23:36:58 -0700 Subject: 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. --- src/syncevo/SmartPtr.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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 eptr : base_t::set(pointer); return *this; } + + void reset(T *pointer = NULL) { + base_t::set(pointer); + } }; template class CxxUnref { -- cgit v1.2.3