From Tim Moore, "This is a patch that allows a ref_ptr to be constructed using an observer_ptr argument, which is locked. This is shorthand for declaring the ref_ptr and then passing it to observer_ptr::lock().
"
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
template<typename T> class observer_ptr;
|
||||
|
||||
/** Smart pointer for handling referenced counted objects.*/
|
||||
template<class T>
|
||||
class ref_ptr
|
||||
@@ -29,7 +31,7 @@ class ref_ptr
|
||||
ref_ptr(T* ptr) : _ptr(ptr) { if (_ptr) _ptr->ref(); }
|
||||
ref_ptr(const ref_ptr& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref(); }
|
||||
template<class Other> ref_ptr(const ref_ptr<Other>& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref(); }
|
||||
|
||||
ref_ptr(observer_ptr<T>& optr) : _ptr(0) { optr.lock(*this); }
|
||||
~ref_ptr() { if (_ptr) _ptr->unref(); _ptr = 0; }
|
||||
|
||||
ref_ptr& operator = (const ref_ptr& rp)
|
||||
|
||||
Reference in New Issue
Block a user