diff options
Diffstat (limited to '3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp b/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp index 2e35583..e3e9ad9 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp +++ b/3rdParty/Boost/src/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<Y> 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<class Y> #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) @@ -97,19 +98,21 @@ public: weak_ptr( weak_ptr<Y> && 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<Y> 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<class Y> - weak_ptr & operator=(weak_ptr<Y> const & r) // never throws + weak_ptr & operator=( weak_ptr<Y> 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<class Y> - weak_ptr & operator=( weak_ptr<Y> && r ) + weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_NOEXCEPT { this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this ); return *this; @@ -154,26 +161,29 @@ public: #endif template<class Y> - weak_ptr & operator=(shared_ptr<Y> const & r) // never throws + weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_NOEXCEPT { + boost::detail::sp_assert_convertible< Y, T >(); + px = r.px; pn = r.pn; + return *this; } #endif - shared_ptr<T> lock() const // never throws + shared_ptr<T> lock() const BOOST_NOEXCEPT { - return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() ); + return shared_ptr<T>( *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<typename Y> + void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2) { px = px2; - pn = pn2; + pn = r.pn; } - template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } - template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( shared_ptr<Y> 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<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) +template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_NOEXCEPT { return a.owner_before( b ); } -template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) +template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_NOEXCEPT { a.swap(b); } |