X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=boost%2Fsmart_ptr%2Fweak_ptr.hpp;h=e3e9ad9bde5c2480affd844e2373300b0da22b6e;hb=08c1e93fa36a49f49325a07fe91ff92c964c2b6c;hp=2e35583be5422b62c41c9e4f6d39b771e4b4b0a0;hpb=bb4dd8289b351fae6b55e303f189127a394a1edd;p=platform%2Fupstream%2Fboost.git diff --git a/boost/smart_ptr/weak_ptr.hpp b/boost/smart_ptr/weak_ptr.hpp index 2e35583..e3e9ad9 100644 --- a/boost/smart_ptr/weak_ptr.hpp +++ b/boost/smart_ptr/weak_ptr.hpp @@ -29,23 +29,23 @@ private: public: - typedef T element_type; + typedef typename boost::detail::sp_element< T >::type element_type; - weak_ptr(): px(0), pn() // never throws in 1.30+ + weak_ptr() BOOST_NOEXCEPT : px(0), pn() // never throws in 1.30+ { } // generated copy constructor, assignment, destructor are fine... -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) // ... except in C++0x, move disables the implicit copy - weak_ptr( weak_ptr const & r ): px( r.px ), pn( r.pn ) // never throws + weak_ptr( weak_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { } - weak_ptr & operator=( weak_ptr const & r ) // never throws + weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT { px = r.px; pn = r.pn; @@ -81,11 +81,12 @@ public: weak_ptr( weak_ptr const & r ) #endif - : px(r.lock().get()), pn(r.pn) // never throws + BOOST_NOEXCEPT : px(r.lock().get()), pn(r.pn) { + boost::detail::sp_assert_convertible< Y, T >(); } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) @@ -97,19 +98,21 @@ public: weak_ptr( weak_ptr && r ) #endif - : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws + BOOST_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) { + boost::detail::sp_assert_convertible< Y, T >(); r.px = 0; } // for better efficiency in the T == Y case - weak_ptr( weak_ptr && r ): px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws + weak_ptr( weak_ptr && r ) + BOOST_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) { r.px = 0; } // for better efficiency in the T == Y case - weak_ptr & operator=( weak_ptr && r ) // never throws + weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; @@ -128,24 +131,28 @@ public: weak_ptr( shared_ptr const & r ) #endif - : px( r.px ), pn( r.pn ) // never throws + BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { + boost::detail::sp_assert_convertible< Y, T >(); } #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) template - weak_ptr & operator=(weak_ptr const & r) // never throws + weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT { + boost::detail::sp_assert_convertible< Y, T >(); + px = r.lock().get(); pn = r.pn; + return *this; } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template - weak_ptr & operator=( weak_ptr && r ) + weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; @@ -154,26 +161,29 @@ public: #endif template - weak_ptr & operator=(shared_ptr const & r) // never throws + weak_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT { + boost::detail::sp_assert_convertible< Y, T >(); + px = r.px; pn = r.pn; + return *this; } #endif - shared_ptr lock() const // never throws + shared_ptr lock() const BOOST_NOEXCEPT { - return shared_ptr( *this, boost::detail::sp_nothrow_tag() ); + return shared_ptr( *this, boost::detail::sp_nothrow_tag() ); } - long use_count() const // never throws + long use_count() const BOOST_NOEXCEPT { return pn.use_count(); } - bool expired() const // never throws + bool expired() const BOOST_NOEXCEPT { return pn.use_count() == 0; } @@ -183,29 +193,30 @@ public: return pn.empty(); } - void reset() // never throws in 1.30+ + void reset() BOOST_NOEXCEPT // never throws in 1.30+ { this_type().swap(*this); } - void swap(this_type & other) // never throws + void swap(this_type & other) BOOST_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } - void _internal_assign(T * px2, boost::detail::shared_count const & pn2) + template + void _internal_aliasing_assign(weak_ptr const & r, element_type * px2) { px = px2; - pn = pn2; + pn = r.pn; } - template bool owner_before( weak_ptr const & rhs ) const + template bool owner_before( weak_ptr const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } - template bool owner_before( shared_ptr const & rhs ) const + template bool owner_before( shared_ptr const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } @@ -222,17 +233,17 @@ private: #endif - T * px; // contained pointer + element_type * px; // contained pointer boost::detail::weak_count pn; // reference counter }; // weak_ptr -template inline bool operator<(weak_ptr const & a, weak_ptr const & b) +template inline bool operator<(weak_ptr const & a, weak_ptr const & b) BOOST_NOEXCEPT { return a.owner_before( b ); } -template void swap(weak_ptr & a, weak_ptr & b) +template void swap(weak_ptr & a, weak_ptr & b) BOOST_NOEXCEPT { a.swap(b); }