Apply BOOST_NOEXCEPT patch. Refs #7523.

[SVN r81368]
This commit is contained in:
Peter Dimov
2012-11-16 15:05:25 +00:00
parent 7adb1cc1ec
commit cf769b94a7
9 changed files with 112 additions and 105 deletions

View File

@ -8,7 +8,7 @@
#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) #if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
operator bool () const operator bool () const BOOST_NOEXCEPT
{ {
return px != 0; return px != 0;
} }
@ -21,7 +21,7 @@
typedef void (*unspecified_bool_type)( this_type*** ); typedef void (*unspecified_bool_type)( this_type*** );
operator unspecified_bool_type() const // never throws operator unspecified_bool_type() const BOOST_NOEXCEPT
{ {
return px == 0? 0: unspecified_bool; return px == 0? 0: unspecified_bool;
} }
@ -33,7 +33,7 @@
typedef element_type * (this_type::*unspecified_bool_type)() const; typedef element_type * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws operator unspecified_bool_type() const BOOST_NOEXCEPT
{ {
return px == 0? 0: &this_type::get; return px == 0? 0: &this_type::get;
} }
@ -42,7 +42,7 @@
typedef element_type * this_type::*unspecified_bool_type; typedef element_type * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const // never throws operator unspecified_bool_type() const BOOST_NOEXCEPT
{ {
return px == 0? 0: &this_type::px; return px == 0? 0: &this_type::px;
} }
@ -50,7 +50,7 @@
#endif #endif
// operator! is redundant, but some compilers need it // operator! is redundant, but some compilers need it
bool operator! () const // never throws bool operator! () const BOOST_NOEXCEPT
{ {
return px == 0; return px == 0;
} }

View File

@ -25,20 +25,20 @@ template<class T> class enable_shared_from_this
{ {
protected: protected:
enable_shared_from_this() enable_shared_from_this() BOOST_NOEXCEPT
{ {
} }
enable_shared_from_this(enable_shared_from_this const &) enable_shared_from_this(enable_shared_from_this const &) BOOST_NOEXCEPT
{ {
} }
enable_shared_from_this & operator=(enable_shared_from_this const &) enable_shared_from_this & operator=(enable_shared_from_this const &) BOOST_NOEXCEPT
{ {
return *this; return *this;
} }
~enable_shared_from_this() ~enable_shared_from_this() BOOST_NOEXCEPT // ~weak_ptr<T> newer throws, so this call also must not throw
{ {
} }

View File

@ -58,7 +58,7 @@ public:
typedef T element_type; typedef T element_type;
intrusive_ptr(): px( 0 ) intrusive_ptr() BOOST_NOEXCEPT : px( 0 )
{ {
} }
@ -110,12 +110,12 @@ public:
#if defined( BOOST_HAS_RVALUE_REFS ) #if defined( BOOST_HAS_RVALUE_REFS )
intrusive_ptr(intrusive_ptr && rhs): px( rhs.px ) intrusive_ptr(intrusive_ptr && rhs) BOOST_NOEXCEPT : px( rhs.px )
{ {
rhs.px = 0; rhs.px = 0;
} }
intrusive_ptr & operator=(intrusive_ptr && rhs) intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_NOEXCEPT
{ {
this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this);
return *this; return *this;
@ -135,7 +135,7 @@ public:
return *this; return *this;
} }
void reset() void reset() BOOST_NOEXCEPT
{ {
this_type().swap( *this ); this_type().swap( *this );
} }
@ -145,7 +145,7 @@ public:
this_type( rhs ).swap( *this ); this_type( rhs ).swap( *this );
} }
T * get() const T * get() const BOOST_NOEXCEPT
{ {
return px; return px;
} }
@ -165,7 +165,7 @@ public:
// implicit conversion to "bool" // implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp> #include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(intrusive_ptr & rhs) void swap(intrusive_ptr & rhs) BOOST_NOEXCEPT
{ {
T * tmp = px; T * tmp = px;
px = rhs.px; px = rhs.px;

View File

@ -67,12 +67,12 @@ private:
public: public:
sp_ms_deleter(): initialized_( false ) sp_ms_deleter() BOOST_NOEXCEPT : initialized_( false )
{ {
} }
// optimization: do not copy storage_ // optimization: do not copy storage_
sp_ms_deleter( sp_ms_deleter const & ): initialized_( false ) sp_ms_deleter( sp_ms_deleter const & ) BOOST_NOEXCEPT : initialized_( false )
{ {
} }
@ -86,12 +86,12 @@ public:
destroy(); destroy();
} }
void * address() void * address() BOOST_NOEXCEPT
{ {
return storage_.data_; return storage_.data_;
} }
void set_initialized() void set_initialized() BOOST_NOEXCEPT
{ {
initialized_ = true; initialized_ = true;
} }
@ -99,7 +99,7 @@ public:
#if defined( BOOST_HAS_RVALUE_REFS ) #if defined( BOOST_HAS_RVALUE_REFS )
template< class T > T&& sp_forward( T & t ) template< class T > T&& sp_forward( T & t ) BOOST_NOEXCEPT
{ {
return static_cast< T&& >( t ); return static_cast< T&& >( t );
} }

View File

@ -53,7 +53,7 @@ public:
typedef T element_type; typedef T element_type;
explicit scoped_array( T * p = 0 ) : px( p ) // never throws explicit scoped_array( T * p = 0 ) BOOST_NOEXCEPT : px( p )
{ {
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_array_constructor_hook( px ); boost::sp_array_constructor_hook( px );
@ -68,20 +68,20 @@ public:
boost::checked_array_delete( px ); boost::checked_array_delete( px );
} }
void reset(T * p = 0) // never throws void reset(T * p = 0) // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
{ {
BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
this_type(p).swap(*this); this_type(p).swap(*this);
} }
T & operator[](std::ptrdiff_t i) const // never throws T & operator[](std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
BOOST_ASSERT( i >= 0 ); BOOST_ASSERT( i >= 0 );
return px[i]; return px[i];
} }
T * get() const // never throws T * get() const BOOST_NOEXCEPT
{ {
return px; return px;
} }
@ -89,7 +89,7 @@ public:
// implicit conversion to "bool" // implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp> #include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_array & b) // never throws void swap(scoped_array & b) BOOST_NOEXCEPT
{ {
T * tmp = b.px; T * tmp = b.px;
b.px = px; b.px = px;
@ -97,7 +97,7 @@ public:
} }
}; };
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) // never throws template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }

View File

@ -63,7 +63,7 @@ public:
#ifndef BOOST_NO_AUTO_PTR #ifndef BOOST_NO_AUTO_PTR
explicit scoped_ptr( std::auto_ptr<T> p ): px( p.release() ) // never throws explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_NOEXCEPT : px( p.release() )
{ {
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_constructor_hook( px ); boost::sp_scalar_constructor_hook( px );
@ -98,7 +98,7 @@ public:
return px; return px;
} }
T * get() const // never throws T * get() const BOOST_NOEXCEPT
{ {
return px; return px;
} }
@ -106,7 +106,7 @@ public:
// implicit conversion to "bool" // implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp> #include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_ptr & b) // never throws void swap(scoped_ptr & b) BOOST_NOEXCEPT
{ {
T * tmp = b.px; T * tmp = b.px;
b.px = px; b.px = px;
@ -114,14 +114,14 @@ public:
} }
}; };
template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) // never throws template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }
// get_pointer(p) is a generic way to say p.get() // get_pointer(p) is a generic way to say p.get()
template<class T> inline T * get_pointer(scoped_ptr<T> const & p) template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_NOEXCEPT
{ {
return p.get(); return p.get();
} }

View File

@ -56,7 +56,7 @@ public:
typedef T element_type; typedef T element_type;
shared_array(): px( 0 ), pn() // never throws shared_array() BOOST_NOEXCEPT : px( 0 ), pn()
{ {
} }
@ -90,11 +90,11 @@ public:
// ... except in C++0x, move disables the implicit copy // ... except in C++0x, move disables the implicit copy
shared_array( shared_array const & r ): px( r.px ), pn( r.pn ) // never throws shared_array( shared_array const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
} }
shared_array( shared_array && r ): px( r.px ), pn() // never throws shared_array( shared_array && r ) BOOST_NOEXCEPT : px( r.px ), pn()
{ {
pn.swap( r.pn ); pn.swap( r.pn );
r.px = 0; r.px = 0;
@ -114,7 +114,7 @@ public:
shared_array( shared_array<Y> const & r ) shared_array( shared_array<Y> const & r )
#endif #endif
: px( r.px ), pn( r.pn ) // never throws BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) // never throws
{ {
boost::detail::sp_assert_convertible< Y[], T[] >(); boost::detail::sp_assert_convertible< Y[], T[] >();
} }
@ -122,13 +122,13 @@ public:
// aliasing // aliasing
template< class Y > template< class Y >
shared_array( shared_array<Y> const & r, element_type * p ): px( p ), pn( r.pn ) // never throws shared_array( shared_array<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn )
{ {
} }
// assignment // assignment
shared_array & operator=( shared_array const & r ) // never throws shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT
{ {
this_type( r ).swap( *this ); this_type( r ).swap( *this );
return *this; return *this;
@ -137,7 +137,7 @@ public:
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
template<class Y> template<class Y>
shared_array & operator=( shared_array<Y> const & r ) // never throws shared_array & operator=( shared_array<Y> const & r ) BOOST_NOEXCEPT
{ {
this_type( r ).swap( *this ); this_type( r ).swap( *this );
return *this; return *this;
@ -147,14 +147,14 @@ public:
#if defined( BOOST_HAS_RVALUE_REFS ) #if defined( BOOST_HAS_RVALUE_REFS )
shared_array & operator=( shared_array && r ) // never throws shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT
{ {
this_type( static_cast< shared_array && >( r ) ).swap( *this ); this_type( static_cast< shared_array && >( r ) ).swap( *this );
return *this; return *this;
} }
template<class Y> template<class Y>
shared_array & operator=( shared_array<Y> && r ) // never throws shared_array & operator=( shared_array<Y> && r ) BOOST_NOEXCEPT
{ {
this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this ); this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this );
return *this; return *this;
@ -162,7 +162,7 @@ public:
#endif #endif
void reset() // never throws void reset() BOOST_NOEXCEPT
{ {
this_type().swap( *this ); this_type().swap( *this );
} }
@ -188,14 +188,14 @@ public:
this_type( r, p ).swap( *this ); this_type( r, p ).swap( *this );
} }
T & operator[] (std::ptrdiff_t i) const // never throws T & operator[] (std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
{ {
BOOST_ASSERT(px != 0); BOOST_ASSERT(px != 0);
BOOST_ASSERT(i >= 0); BOOST_ASSERT(i >= 0);
return px[i]; return px[i];
} }
T * get() const // never throws T * get() const BOOST_NOEXCEPT
{ {
return px; return px;
} }
@ -203,17 +203,17 @@ public:
// implicit conversion to "bool" // implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp> #include <boost/smart_ptr/detail/operator_bool.hpp>
bool unique() const // never throws bool unique() const BOOST_NOEXCEPT
{ {
return pn.unique(); return pn.unique();
} }
long use_count() const // never throws long use_count() const BOOST_NOEXCEPT
{ {
return pn.use_count(); return pn.use_count();
} }
void swap(shared_array<T> & other) // never throws void swap(shared_array<T> & other) BOOST_NOEXCEPT
{ {
std::swap(px, other.px); std::swap(px, other.px);
pn.swap(other.pn); pn.swap(other.pn);
@ -233,22 +233,22 @@ private:
}; // shared_array }; // shared_array
template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) // never throws template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{ {
return a.get() == b.get(); return a.get() == b.get();
} }
template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
{ {
return std::less<T*>()(a.get(), b.get()); return std::less<T*>()(a.get(), b.get());
} }
template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }

View File

@ -324,7 +324,7 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type; typedef typename boost::detail::sp_element< T >::type element_type;
shared_ptr(): px( 0 ), pn() // never throws in 1.30+ shared_ptr() BOOST_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+
{ {
} }
@ -358,7 +358,7 @@ public:
// ... except in C++0x, move disables the implicit copy // ... except in C++0x, move disables the implicit copy
shared_ptr( shared_ptr const & r ): px( r.px ), pn( r.pn ) // never throws shared_ptr( shared_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
} }
@ -374,7 +374,8 @@ public:
} }
template<class Y> template<class Y>
shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag ): px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() ) // never throws shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag )
BOOST_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() )
{ {
if( !pn.empty() ) if( !pn.empty() )
{ {
@ -392,24 +393,26 @@ public:
shared_ptr( shared_ptr<Y> const & r ) shared_ptr( shared_ptr<Y> const & r )
#endif #endif
: px( r.px ), pn( r.pn ) // never throws BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
} }
// aliasing // aliasing
template< class Y > template< class Y >
shared_ptr( shared_ptr<Y> const & r, element_type * p ): px( p ), pn( r.pn ) // never throws shared_ptr( shared_ptr<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn )
{ {
} }
template<class Y> template<class Y>
shared_ptr(shared_ptr<Y> const & r, boost::detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn) shared_ptr(shared_ptr<Y> const & r, boost::detail::static_cast_tag)
BOOST_NOEXCEPT : px(static_cast<element_type *>(r.px)), pn(r.pn)
{ {
} }
template<class Y> template<class Y>
shared_ptr(shared_ptr<Y> const & r, boost::detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn) shared_ptr(shared_ptr<Y> const & r, boost::detail::const_cast_tag)
BOOST_NOEXCEPT : px(const_cast<element_type *>(r.px)), pn(r.pn)
{ {
} }
@ -480,7 +483,7 @@ public:
// assignment // assignment
shared_ptr & operator=( shared_ptr const & r ) // never throws shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT
{ {
this_type(r).swap(*this); this_type(r).swap(*this);
return *this; return *this;
@ -489,7 +492,7 @@ public:
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
template<class Y> template<class Y>
shared_ptr & operator=(shared_ptr<Y> const & r) // never throws shared_ptr & operator=(shared_ptr<Y> const & r) BOOST_NOEXCEPT
{ {
this_type(r).swap(*this); this_type(r).swap(*this);
return *this; return *this;
@ -523,7 +526,7 @@ public:
#if defined( BOOST_HAS_RVALUE_REFS ) #if defined( BOOST_HAS_RVALUE_REFS )
shared_ptr( shared_ptr && r ): px( r.px ), pn() // never throws shared_ptr( shared_ptr && r ) BOOST_NOEXCEPT : px( r.px ), pn()
{ {
pn.swap( r.pn ); pn.swap( r.pn );
r.px = 0; r.px = 0;
@ -539,7 +542,7 @@ public:
shared_ptr( shared_ptr<Y> && r ) shared_ptr( shared_ptr<Y> && r )
#endif #endif
: px( r.px ), pn() // never throws BOOST_NOEXCEPT : px( r.px ), pn()
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
@ -547,14 +550,14 @@ public:
r.px = 0; r.px = 0;
} }
shared_ptr & operator=( shared_ptr && r ) // never throws shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT
{ {
this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
return *this; return *this;
} }
template<class Y> template<class Y>
shared_ptr & operator=( shared_ptr<Y> && r ) // never throws shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_NOEXCEPT
{ {
this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this ); this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
return *this; return *this;
@ -562,7 +565,7 @@ public:
#endif #endif
void reset() // never throws in 1.30+ void reset() BOOST_NOEXCEPT // never throws in 1.30+
{ {
this_type().swap(*this); this_type().swap(*this);
} }
@ -587,20 +590,23 @@ public:
{ {
this_type( r, p ).swap( *this ); this_type( r, p ).swap( *this );
} }
typename boost::detail::sp_dereference< T >::type operator* () const // never throws // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
typename boost::detail::sp_dereference< T >::type operator* () const
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return *px; return *px;
} }
typename boost::detail::sp_member_access< T >::type operator-> () const // never throws // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
typename boost::detail::sp_member_access< T >::type operator-> () const
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return px; return px;
} }
typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const // never throws // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) ); BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
@ -608,7 +614,7 @@ public:
return px[ i ]; return px[ i ];
} }
element_type * get() const // never throws element_type * get() const BOOST_NOEXCEPT
{ {
return px; return px;
} }
@ -616,28 +622,28 @@ public:
// implicit conversion to "bool" // implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp> #include <boost/smart_ptr/detail/operator_bool.hpp>
bool unique() const // never throws bool unique() const BOOST_NOEXCEPT
{ {
return pn.unique(); return pn.unique();
} }
long use_count() const // never throws long use_count() const BOOST_NOEXCEPT
{ {
return pn.use_count(); return pn.use_count();
} }
void swap( shared_ptr & other ) // never throws void swap( shared_ptr & other ) BOOST_NOEXCEPT
{ {
std::swap(px, other.px); std::swap(px, other.px);
pn.swap(other.pn); pn.swap(other.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; return pn < rhs.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; return pn < rhs.pn;
} }
@ -647,7 +653,7 @@ public:
return pn.get_deleter( ti ); return pn.get_deleter( ti );
} }
bool _internal_equiv( shared_ptr const & r ) const bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT
{ {
return px == r.px && pn == r.pn; return px == r.px && pn == r.pn;
} }
@ -670,12 +676,12 @@ private:
}; // shared_ptr }; // shared_ptr
template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
{ {
return a.get() == b.get(); return a.get() == b.get();
} }
template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
@ -684,19 +690,19 @@ template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, share
// Resolve the ambiguity between our op!= and the one in rel_ops // Resolve the ambiguity between our op!= and the one in rel_ops
template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) BOOST_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
#endif #endif
template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
{ {
return a.owner_before( b ); return a.owner_before( b );
} }
template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) BOOST_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }
@ -741,7 +747,7 @@ template<class T, class U> shared_ptr<T> shared_polymorphic_downcast(shared_ptr<
// get_pointer() enables boost::mem_fn to recognize shared_ptr // get_pointer() enables boost::mem_fn to recognize shared_ptr
template<class T> inline T * get_pointer(shared_ptr<T> const & p) template<class T> inline T * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT
{ {
return p.get(); return p.get();
} }
@ -854,7 +860,7 @@ template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
#if !defined(BOOST_SP_NO_ATOMIC_ACCESS) #if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_NOEXCEPT
{ {
return false; return false;
} }
@ -933,7 +939,7 @@ template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> *
template< class T > struct hash; template< class T > struct hash;
template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT
{ {
return boost::hash< T* >()( p.get() ); return boost::hash< T* >()( p.get() );
} }

View File

@ -31,7 +31,7 @@ public:
typedef typename boost::detail::sp_element< T >::type 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+
{ {
} }
@ -41,11 +41,11 @@ public:
// ... except in C++0x, move disables the implicit copy // ... 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; px = r.px;
pn = r.pn; pn = r.pn;
@ -81,7 +81,7 @@ public:
weak_ptr( weak_ptr<Y> const & r ) weak_ptr( weak_ptr<Y> const & r )
#endif #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 >(); boost::detail::sp_assert_convertible< Y, T >();
} }
@ -98,20 +98,21 @@ public:
weak_ptr( weak_ptr<Y> && r ) weak_ptr( weak_ptr<Y> && r )
#endif #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 >(); boost::detail::sp_assert_convertible< Y, T >();
r.px = 0; r.px = 0;
} }
// for better efficiency in the T == Y case // 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; r.px = 0;
} }
// for better efficiency in the T == Y case // 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 ); this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
return *this; return *this;
@ -130,7 +131,7 @@ public:
weak_ptr( shared_ptr<Y> const & r ) weak_ptr( shared_ptr<Y> const & r )
#endif #endif
: px( r.px ), pn( r.pn ) // never throws BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
} }
@ -138,7 +139,7 @@ public:
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
template<class Y> 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 >(); boost::detail::sp_assert_convertible< Y, T >();
@ -151,7 +152,7 @@ public:
#if defined( BOOST_HAS_RVALUE_REFS ) #if defined( BOOST_HAS_RVALUE_REFS )
template<class Y> 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 ); this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
return *this; return *this;
@ -160,7 +161,7 @@ public:
#endif #endif
template<class Y> 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 >(); boost::detail::sp_assert_convertible< Y, T >();
@ -172,17 +173,17 @@ public:
#endif #endif
shared_ptr<T> lock() const // never throws shared_ptr<T> lock() const BOOST_NOEXCEPT
{ {
return shared_ptr<T>( *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(); return pn.use_count();
} }
bool expired() const // never throws bool expired() const BOOST_NOEXCEPT
{ {
return pn.use_count() == 0; return pn.use_count() == 0;
} }
@ -192,12 +193,12 @@ public:
return pn.empty(); return pn.empty();
} }
void reset() // never throws in 1.30+ void reset() BOOST_NOEXCEPT // never throws in 1.30+
{ {
this_type().swap(*this); this_type().swap(*this);
} }
void swap(this_type & other) // never throws void swap(this_type & other) BOOST_NOEXCEPT
{ {
std::swap(px, other.px); std::swap(px, other.px);
pn.swap(other.pn); pn.swap(other.pn);
@ -210,12 +211,12 @@ public:
pn = r.pn; 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; 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; return pn < rhs.pn;
} }
@ -237,12 +238,12 @@ private:
}; // weak_ptr }; // 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 ); 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); a.swap(b);
} }