File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222#include < string>
2323#endif
2424
25+ #if __cplusplus >= 201103L
26+ #include < utility>
27+ #endif
28+
2529namespace osg {
2630
2731template <typename T> class observer_ptr ;
@@ -36,6 +40,9 @@ class ref_ptr
3640 ref_ptr () : _ptr(0 ) {}
3741 ref_ptr (T* ptr) : _ptr(ptr) { if (_ptr) _ptr->ref (); }
3842 ref_ptr (const ref_ptr& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref (); }
43+ #if __cplusplus >= 201103L
44+ ref_ptr (ref_ptr&& rp) noexcept : _ptr(rp._ptr) { rp._ptr = 0 ; }
45+ #endif
3946 template <class Other > ref_ptr (const ref_ptr<Other>& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref (); }
4047 ref_ptr (observer_ptr<T>& optr) : _ptr(0 ) { optr.lock (*this ); }
4148 ~ref_ptr () { if (_ptr) _ptr->unref (); _ptr = 0 ; }
@@ -52,6 +59,17 @@ class ref_ptr
5259 return *this ;
5360 }
5461
62+ #if __cplusplus >= 201103L
63+ template <class Other > ref_ptr& operator = (ref_ptr<Other>&& rp)
64+ {
65+ if (_ptr == rp._ptr ) return *this ;
66+ if (_ptr != nullptr ) _ptr->unref ();
67+ _ptr = rp._ptr ;
68+ rp._ptr = nullptr ;
69+ return *this ;
70+ }
71+ #endif
72+
5573 inline ref_ptr& operator = (T* ptr)
5674 {
5775 if (_ptr==ptr) return *this ;
You can’t perform that action at this time.
0 commit comments