SGSharedPtr: add constructor to convert from SGWeakPtr.
This commit is contained in:
parent
67a8d8049f
commit
7d9797e091
@ -60,6 +60,9 @@ public:
|
||||
template<typename U>
|
||||
SGSharedPtr(const SGSharedPtr<U>& p) : _ptr(p.get())
|
||||
{ get(_ptr); }
|
||||
template<typename U>
|
||||
explicit SGSharedPtr(const SGWeakPtr<U>& p): _ptr(0)
|
||||
{ reset(p.lock().get()); }
|
||||
~SGSharedPtr(void)
|
||||
{ reset(); }
|
||||
|
||||
|
@ -72,6 +72,9 @@ BOOST_AUTO_TEST_CASE( virtual_weak_ptr )
|
||||
SGSharedPtr<Base1> ptr1( weak_ptr.lock() );
|
||||
BOOST_REQUIRE_EQUAL( ptr.getNumRefs(), 2 );
|
||||
|
||||
// converting constructor
|
||||
BOOST_REQUIRE_EQUAL( SGSharedPtr<Base1>(weak_ptr), ptr1 );
|
||||
|
||||
SGSharedPtr<Base2> ptr2( weak_ptr.lock() );
|
||||
BOOST_REQUIRE_EQUAL( ptr.getNumRefs(), 3 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user