Use BOOST_SP_NOEXCEPT, BOOST_SP_NOEXCEPT_WITH_ASSERT

This commit is contained in:
Peter Dimov
2017-06-12 18:06:54 +03:00
parent e75fa9329b
commit 52d976fde2
15 changed files with 264 additions and 246 deletions

View File

@ -11,33 +11,34 @@
#define BOOST_POINTER_CAST_HPP #define BOOST_POINTER_CAST_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
namespace boost { namespace boost {
//static_pointer_cast overload for raw pointers //static_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* static_pointer_cast(U *ptr) inline T* static_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{ {
return static_cast<T*>(ptr); return static_cast<T*>(ptr);
} }
//dynamic_pointer_cast overload for raw pointers //dynamic_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* dynamic_pointer_cast(U *ptr) inline T* dynamic_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{ {
return dynamic_cast<T*>(ptr); return dynamic_cast<T*>(ptr);
} }
//const_pointer_cast overload for raw pointers //const_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* const_pointer_cast(U *ptr) inline T* const_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{ {
return const_cast<T*>(ptr); return const_cast<T*>(ptr);
} }
//reinterpret_pointer_cast overload for raw pointers //reinterpret_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* reinterpret_pointer_cast(U *ptr) inline T* reinterpret_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{ {
return reinterpret_cast<T*>(ptr); return reinterpret_cast<T*>(ptr);
} }
@ -62,7 +63,7 @@ using std::dynamic_pointer_cast;
using std::const_pointer_cast; using std::const_pointer_cast;
//reinterpret_pointer_cast overload for std::shared_ptr //reinterpret_pointer_cast overload for std::shared_ptr
template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) BOOST_NOEXCEPT template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) BOOST_SP_NOEXCEPT
{ {
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@ -73,7 +74,7 @@ template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std
} }
//static_pointer_cast overload for std::unique_ptr //static_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) static_cast< T* >( static_cast< U* >( 0 ) ); (void) static_cast< T* >( static_cast< U* >( 0 ) );
@ -83,7 +84,7 @@ template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_p
} }
//dynamic_pointer_cast overload for std::unique_ptr //dynamic_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
@ -95,7 +96,7 @@ template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_
} }
//const_pointer_cast overload for std::unique_ptr //const_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) const_cast< T* >( static_cast< U* >( 0 ) ); (void) const_cast< T* >( static_cast< U* >( 0 ) );
@ -105,7 +106,7 @@ template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_pt
} }
//reinterpret_pointer_cast overload for std::unique_ptr //reinterpret_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::unique_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );

View File

@ -9,6 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP #define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
#include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/has_trivial_constructor.hpp> #include <boost/type_traits/has_trivial_constructor.hpp>
#include <boost/type_traits/has_trivial_copy.hpp> #include <boost/type_traits/has_trivial_copy.hpp>
@ -111,7 +112,7 @@ struct sp_array_count<T[]> { };
template<class D, class T> template<class D, class T>
inline D* inline D*
sp_get_deleter(const boost::shared_ptr<T>& value) BOOST_NOEXCEPT_OR_NOTHROW sp_get_deleter(const boost::shared_ptr<T>& value) BOOST_SP_NOEXCEPT
{ {
return static_cast<D*>(value._internal_get_untyped_deleter()); return static_cast<D*>(value._internal_get_untyped_deleter());
} }
@ -153,7 +154,7 @@ struct sp_enable<true, T> {
template<class T> template<class T>
inline typename sp_enable<boost::has_trivial_destructor<T>::value>::type inline typename sp_enable<boost::has_trivial_destructor<T>::value>::type
sp_array_destroy(T*, std::size_t) BOOST_NOEXCEPT { } sp_array_destroy(T*, std::size_t) BOOST_SP_NOEXCEPT { }
template<class T> template<class T>
inline typename sp_enable<!boost::has_trivial_destructor<T>::value>::type inline typename sp_enable<!boost::has_trivial_destructor<T>::value>::type
@ -308,7 +309,7 @@ sp_array_construct(A& allocator, T* storage, std::size_t size,
template<class T> template<class T>
inline typename sp_enable<boost::has_trivial_constructor<T>::value>::type inline typename sp_enable<boost::has_trivial_constructor<T>::value>::type
sp_array_default(T*, std::size_t) BOOST_NOEXCEPT { } sp_array_default(T*, std::size_t) BOOST_SP_NOEXCEPT { }
#if !defined(BOOST_NO_EXCEPTIONS) #if !defined(BOOST_NO_EXCEPTIONS)
template<class T> template<class T>
@ -357,7 +358,7 @@ struct sp_less_align {
template<class T, std::size_t N> template<class T, std::size_t N>
BOOST_CONSTEXPR BOOST_CONSTEXPR
inline typename sp_enable<sp_less_align<T, N>::value, std::size_t>::type inline typename sp_enable<sp_less_align<T, N>::value, std::size_t>::type
sp_align(std::size_t size) BOOST_NOEXCEPT sp_align(std::size_t size) BOOST_SP_NOEXCEPT
{ {
return (sizeof(T) * size + N - 1) & ~(N - 1); return (sizeof(T) * size + N - 1) & ~(N - 1);
} }
@ -365,14 +366,14 @@ sp_align(std::size_t size) BOOST_NOEXCEPT
template<class T, std::size_t N> template<class T, std::size_t N>
BOOST_CONSTEXPR BOOST_CONSTEXPR
inline typename sp_enable<!sp_less_align<T, N>::value, std::size_t>::type inline typename sp_enable<!sp_less_align<T, N>::value, std::size_t>::type
sp_align(std::size_t size) BOOST_NOEXCEPT sp_align(std::size_t size) BOOST_SP_NOEXCEPT
{ {
return sizeof(T) * size; return sizeof(T) * size;
} }
template<class T> template<class T>
BOOST_CONSTEXPR inline std::size_t BOOST_CONSTEXPR inline std::size_t
sp_types(std::size_t size) BOOST_NOEXCEPT sp_types(std::size_t size) BOOST_SP_NOEXCEPT
{ {
return (size + sizeof(T) - 1) / sizeof(T); return (size + sizeof(T) - 1) / sizeof(T);
} }
@ -381,16 +382,16 @@ template<class T, std::size_t N>
class sp_size_array_deleter { class sp_size_array_deleter {
public: public:
template<class U> template<class U>
static void operator_fn(U) BOOST_NOEXCEPT { } static void operator_fn(U) BOOST_SP_NOEXCEPT { }
sp_size_array_deleter() BOOST_NOEXCEPT sp_size_array_deleter() BOOST_SP_NOEXCEPT
: enabled_(false) { } : enabled_(false) { }
template<class A> template<class A>
sp_size_array_deleter(const A&) BOOST_NOEXCEPT sp_size_array_deleter(const A&) BOOST_SP_NOEXCEPT
: enabled_(false) { } : enabled_(false) { }
sp_size_array_deleter(const sp_size_array_deleter&) BOOST_NOEXCEPT sp_size_array_deleter(const sp_size_array_deleter&) BOOST_SP_NOEXCEPT
: enabled_(false) { } : enabled_(false) { }
~sp_size_array_deleter() { ~sp_size_array_deleter() {
@ -436,15 +437,15 @@ template<class T, std::size_t N, class A>
class sp_size_array_destroyer { class sp_size_array_destroyer {
public: public:
template<class U> template<class U>
static void operator_fn(U) BOOST_NOEXCEPT { } static void operator_fn(U) BOOST_SP_NOEXCEPT { }
template<class U> template<class U>
sp_size_array_destroyer(const U& allocator) BOOST_NOEXCEPT sp_size_array_destroyer(const U& allocator) BOOST_SP_NOEXCEPT
: allocator_(allocator), : allocator_(allocator),
enabled_(false) { } enabled_(false) { }
sp_size_array_destroyer(const sp_size_array_destroyer& other) sp_size_array_destroyer(const sp_size_array_destroyer& other)
BOOST_NOEXCEPT BOOST_SP_NOEXCEPT
: allocator_(other.allocator_), : allocator_(other.allocator_),
enabled_(false) { } enabled_(false) { }
@ -475,7 +476,7 @@ public:
return &storage_; return &storage_;
} }
const A& allocator() const BOOST_NOEXCEPT { const A& allocator() const BOOST_SP_NOEXCEPT {
return allocator_; return allocator_;
} }
@ -491,23 +492,23 @@ template<class T>
class sp_array_deleter { class sp_array_deleter {
public: public:
template<class U> template<class U>
static void operator_fn(U) BOOST_NOEXCEPT { } static void operator_fn(U) BOOST_SP_NOEXCEPT { }
sp_array_deleter(std::size_t size) BOOST_NOEXCEPT sp_array_deleter(std::size_t size) BOOST_SP_NOEXCEPT
: address_(0), : address_(0),
size_(size) { } size_(size) { }
template<class A> template<class A>
sp_array_deleter(const A& allocator) BOOST_NOEXCEPT sp_array_deleter(const A& allocator) BOOST_SP_NOEXCEPT
: address_(0), : address_(0),
size_(allocator.size()) { } size_(allocator.size()) { }
template<class A> template<class A>
sp_array_deleter(const A&, std::size_t size) BOOST_NOEXCEPT sp_array_deleter(const A&, std::size_t size) BOOST_SP_NOEXCEPT
: address_(0), : address_(0),
size_(size) { } size_(size) { }
sp_array_deleter(const sp_array_deleter& other) BOOST_NOEXCEPT sp_array_deleter(const sp_array_deleter& other) BOOST_SP_NOEXCEPT
: address_(0), : address_(0),
size_(other.size_) { } size_(other.size_) { }
@ -540,7 +541,7 @@ public:
address_ = address; address_ = address;
} }
std::size_t size() const BOOST_NOEXCEPT { std::size_t size() const BOOST_SP_NOEXCEPT {
return size_; return size_;
} }
@ -554,21 +555,21 @@ template<class T, class A>
class sp_array_destroyer { class sp_array_destroyer {
public: public:
template<class U> template<class U>
static void operator_fn(U) BOOST_NOEXCEPT { } static void operator_fn(U) BOOST_SP_NOEXCEPT { }
template<class U> template<class U>
sp_array_destroyer(const U& allocator, std::size_t size) BOOST_NOEXCEPT sp_array_destroyer(const U& allocator, std::size_t size) BOOST_SP_NOEXCEPT
: allocator_(allocator), : allocator_(allocator),
size_(size), size_(size),
address_(0) { } address_(0) { }
template<class U> template<class U>
sp_array_destroyer(const U& allocator) BOOST_NOEXCEPT sp_array_destroyer(const U& allocator) BOOST_SP_NOEXCEPT
: allocator_(allocator.allocator()), : allocator_(allocator.allocator()),
size_(allocator.size()), size_(allocator.size()),
address_(0) { } address_(0) { }
sp_array_destroyer(const sp_array_destroyer& other) BOOST_NOEXCEPT sp_array_destroyer(const sp_array_destroyer& other) BOOST_SP_NOEXCEPT
: allocator_(other.allocator_), : allocator_(other.allocator_),
size_(other.size_), size_(other.size_),
address_(0) { } address_(0) { }
@ -597,11 +598,11 @@ public:
address_ = address; address_ = address;
} }
const A& allocator() const BOOST_NOEXCEPT { const A& allocator() const BOOST_SP_NOEXCEPT {
return allocator_; return allocator_;
} }
std::size_t size() const BOOST_NOEXCEPT { std::size_t size() const BOOST_SP_NOEXCEPT {
return size_; return size_;
} }
@ -637,17 +638,17 @@ public:
}; };
sp_array_allocator(const A& allocator, std::size_t size, void** result) sp_array_allocator(const A& allocator, std::size_t size, void** result)
BOOST_NOEXCEPT BOOST_SP_NOEXCEPT
: allocator_(allocator), : allocator_(allocator),
size_(size), size_(size),
result_(result) { } result_(result) { }
sp_array_allocator(const A& allocator, std::size_t size) BOOST_NOEXCEPT sp_array_allocator(const A& allocator, std::size_t size) BOOST_SP_NOEXCEPT
: allocator_(allocator), : allocator_(allocator),
size_(size) { } size_(size) { }
template<class U> template<class U>
sp_array_allocator(const sp_array_allocator<T, U>& other) BOOST_NOEXCEPT sp_array_allocator(const sp_array_allocator<T, U>& other) BOOST_SP_NOEXCEPT
: allocator_(other.allocator_), : allocator_(other.allocator_),
size_(other.size_), size_(other.size_),
result_(other.result_) { } result_(other.result_) { }
@ -668,11 +669,11 @@ public:
allocator.deallocate(reinterpret_cast<type*>(value), size); allocator.deallocate(reinterpret_cast<type*>(value), size);
} }
const A& allocator() const BOOST_NOEXCEPT { const A& allocator() const BOOST_SP_NOEXCEPT {
return allocator_; return allocator_;
} }
std::size_t size() const BOOST_NOEXCEPT { std::size_t size() const BOOST_SP_NOEXCEPT {
return size_; return size_;
} }
@ -685,7 +686,7 @@ private:
template<class T, class U, class V> template<class T, class U, class V>
inline bool inline bool
operator==(const sp_array_allocator<T, U>& first, operator==(const sp_array_allocator<T, U>& first,
const sp_array_allocator<T, V>& second) BOOST_NOEXCEPT const sp_array_allocator<T, V>& second) BOOST_SP_NOEXCEPT
{ {
return first.allocator() == second.allocator() && return first.allocator() == second.allocator() &&
first.size() == second.size(); first.size() == second.size();
@ -694,7 +695,7 @@ operator==(const sp_array_allocator<T, U>& first,
template<class T, class U, class V> template<class T, class U, class V>
inline bool inline bool
operator!=(const sp_array_allocator<T, U>& first, operator!=(const sp_array_allocator<T, U>& first,
const sp_array_allocator<T, V>& second) BOOST_NOEXCEPT const sp_array_allocator<T, V>& second) BOOST_SP_NOEXCEPT
{ {
return !(first == second); return !(first == second);
} }

View File

@ -44,7 +44,7 @@ private:
public: public:
BOOST_CONSTEXPR local_counted_base() BOOST_NOEXCEPT: local_use_count_( initial_ ) BOOST_CONSTEXPR local_counted_base() BOOST_SP_NOEXCEPT: local_use_count_( initial_ )
{ {
} }
@ -75,7 +75,7 @@ public:
} }
} }
long local_use_count() const BOOST_NOEXCEPT long local_use_count() const BOOST_SP_NOEXCEPT
{ {
return local_use_count_; return local_use_count_;
} }

View File

@ -9,14 +9,14 @@
#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\ #if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\
&& !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) && !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
explicit operator bool () const BOOST_NOEXCEPT explicit operator bool () const BOOST_SP_NOEXCEPT
{ {
return px != 0; return px != 0;
} }
#elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) #elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
operator bool () const BOOST_NOEXCEPT operator bool () const BOOST_SP_NOEXCEPT
{ {
return px != 0; return px != 0;
} }
@ -29,7 +29,7 @@
typedef void (*unspecified_bool_type)( this_type*** ); typedef void (*unspecified_bool_type)( this_type*** );
operator unspecified_bool_type() const BOOST_NOEXCEPT operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{ {
return px == 0? 0: unspecified_bool; return px == 0? 0: unspecified_bool;
} }
@ -41,7 +41,7 @@
typedef element_type * (this_type::*unspecified_bool_type)() const; typedef element_type * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const BOOST_NOEXCEPT operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{ {
return px == 0? 0: &this_type::get; return px == 0? 0: &this_type::get;
} }
@ -50,7 +50,7 @@
typedef element_type * this_type::*unspecified_bool_type; typedef element_type * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const BOOST_NOEXCEPT operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{ {
return px == 0? 0: &this_type::px; return px == 0? 0: &this_type::px;
} }
@ -58,7 +58,7 @@
#endif #endif
// operator! is redundant, but some compilers need it // operator! is redundant, but some compilers need it
bool operator! () const BOOST_NOEXCEPT bool operator! () const BOOST_SP_NOEXCEPT
{ {
return px == 0; return px == 0;
} }

View File

@ -9,7 +9,7 @@
// detail/sp_noexcept.hpp // detail/sp_noexcept.hpp
// //
// Copyright 2016 Peter Dimov // Copyright 2016, 2017 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at // See accompanying file LICENSE_1_0.txt or copy at
@ -17,13 +17,31 @@
#include <boost/config.hpp> #include <boost/config.hpp>
// BOOST_SP_NOEXCEPT
#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1700 && BOOST_MSVC < 1900 #if defined( BOOST_MSVC ) && BOOST_MSVC >= 1700 && BOOST_MSVC < 1900
#define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW # define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW
#else #else
#define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT # define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT
#endif
// BOOST_SP_NOEXCEPT_WITH_ASSERT
#if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
# define BOOST_SP_NOEXCEPT_WITH_ASSERT BOOST_SP_NOEXCEPT
#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
# define BOOST_SP_NOEXCEPT_WITH_ASSERT
#else
# define BOOST_SP_NOEXCEPT_WITH_ASSERT BOOST_SP_NOEXCEPT
#endif #endif

View File

@ -59,12 +59,12 @@ public:
return p; return p;
} }
weak_ptr<T> weak_from_this() BOOST_NOEXCEPT weak_ptr<T> weak_from_this() BOOST_SP_NOEXCEPT
{ {
return weak_this_; return weak_this_;
} }
weak_ptr<T const> weak_from_this() const BOOST_NOEXCEPT weak_ptr<T const> weak_from_this() const BOOST_SP_NOEXCEPT
{ {
return weak_this_; return weak_this_;
} }
@ -72,7 +72,7 @@ public:
public: // actually private, but avoids compiler template friendship issues public: // actually private, but avoids compiler template friendship issues
// Note: invoked automatically by shared_ptr; do not call // Note: invoked automatically by shared_ptr; do not call
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> const * ppx, Y * py ) const template<class X, class Y> void _internal_accept_owner( shared_ptr<X> const * ppx, Y * py ) const BOOST_SP_NOEXCEPT
{ {
if( weak_this_.expired() ) if( weak_this_.expired() )
{ {

View File

@ -141,7 +141,7 @@ public:
} }
template<class U> template<class U>
intrusive_ptr & operator=(intrusive_ptr<U> && rhs) BOOST_NOEXCEPT intrusive_ptr & operator=(intrusive_ptr<U> && rhs) BOOST_SP_NOEXCEPT
{ {
this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this); this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this);
return *this; return *this;
@ -161,7 +161,7 @@ public:
return *this; return *this;
} }
void reset() BOOST_NOEXCEPT void reset()
{ {
this_type().swap( *this ); this_type().swap( *this );
} }
@ -176,25 +176,25 @@ public:
this_type( rhs, add_ref ).swap( *this ); this_type( rhs, add_ref ).swap( *this );
} }
T * get() const BOOST_NOEXCEPT T * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
T * detach() BOOST_NOEXCEPT T * detach() BOOST_SP_NOEXCEPT
{ {
T * ret = px; T * ret = px;
px = 0; px = 0;
return ret; return ret;
} }
T & operator*() const T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return *px; return *px;
} }
T * operator->() const T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return px; return px;
@ -203,7 +203,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) BOOST_NOEXCEPT void swap(intrusive_ptr & rhs) BOOST_SP_NOEXCEPT
{ {
T * tmp = px; T * tmp = px;
px = rhs.px; px = rhs.px;
@ -215,32 +215,32 @@ private:
T * px; T * px;
}; };
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() == b.get(); return a.get() == b.get();
} }
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, U * b) template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, U * b) BOOST_SP_NOEXCEPT
{ {
return a.get() == b; return a.get() == b;
} }
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, U * b) template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, U * b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b; return a.get() != b;
} }
template<class T, class U> inline bool operator==(T * a, intrusive_ptr<U> const & b) template<class T, class U> inline bool operator==(T * a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a == b.get(); return a == b.get();
} }
template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const & b) template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a != b.get(); return a != b.get();
} }
@ -249,7 +249,7 @@ template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const
// 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!=(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) template<class T> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
@ -258,41 +258,41 @@ template<class T> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_p
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator==( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator!=( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator!=( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
#endif #endif
template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) BOOST_SP_NOEXCEPT
{ {
return std::less<T *>()(a.get(), b.get()); return std::less<T *>()(a.get(), b.get());
} }
template<class T> void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) template<class T> void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) BOOST_SP_NOEXCEPT
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
// mem_fn support // mem_fn support
template<class T> T * get_pointer(intrusive_ptr<T> const & p) template<class T> T * get_pointer(intrusive_ptr<T> const & p) BOOST_SP_NOEXCEPT
{ {
return p.get(); return p.get();
} }
@ -351,7 +351,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
template< class T > struct hash; template< class T > struct hash;
template< class T > std::size_t hash_value( boost::intrusive_ptr<T> const & p ) template< class T > std::size_t hash_value( boost::intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return boost::hash< T* >()( p.get() ); return boost::hash< T* >()( p.get() );
} }

View File

@ -17,6 +17,7 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/smart_ptr/detail/atomic_count.hpp> #include <boost/smart_ptr/detail/atomic_count.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE #ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once #pragma once
@ -45,17 +46,17 @@ struct thread_unsafe_counter
{ {
typedef unsigned int type; typedef unsigned int type;
static unsigned int load(unsigned int const& counter) BOOST_NOEXCEPT static unsigned int load(unsigned int const& counter) BOOST_SP_NOEXCEPT
{ {
return counter; return counter;
} }
static void increment(unsigned int& counter) BOOST_NOEXCEPT static void increment(unsigned int& counter) BOOST_SP_NOEXCEPT
{ {
++counter; ++counter;
} }
static unsigned int decrement(unsigned int& counter) BOOST_NOEXCEPT static unsigned int decrement(unsigned int& counter) BOOST_SP_NOEXCEPT
{ {
return --counter; return --counter;
} }
@ -71,17 +72,17 @@ struct thread_safe_counter
{ {
typedef boost::detail::atomic_count type; typedef boost::detail::atomic_count type;
static unsigned int load(boost::detail::atomic_count const& counter) BOOST_NOEXCEPT static unsigned int load(boost::detail::atomic_count const& counter) BOOST_SP_NOEXCEPT
{ {
return static_cast< unsigned int >(static_cast< long >(counter)); return static_cast< unsigned int >(static_cast< long >(counter));
} }
static void increment(boost::detail::atomic_count& counter) BOOST_NOEXCEPT static void increment(boost::detail::atomic_count& counter) BOOST_SP_NOEXCEPT
{ {
++counter; ++counter;
} }
static unsigned int decrement(boost::detail::atomic_count& counter) BOOST_NOEXCEPT static unsigned int decrement(boost::detail::atomic_count& counter) BOOST_SP_NOEXCEPT
{ {
return static_cast< unsigned int >(--counter); return static_cast< unsigned int >(--counter);
} }
@ -91,9 +92,9 @@ template< typename DerivedT, typename CounterPolicyT = thread_safe_counter >
class intrusive_ref_counter; class intrusive_ref_counter;
template< typename DerivedT, typename CounterPolicyT > template< typename DerivedT, typename CounterPolicyT >
void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT; void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
template< typename DerivedT, typename CounterPolicyT > template< typename DerivedT, typename CounterPolicyT >
void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT; void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
/*! /*!
* \brief A reference counter base class * \brief A reference counter base class
@ -121,7 +122,7 @@ public:
* *
* \post <tt>use_count() == 0</tt> * \post <tt>use_count() == 0</tt>
*/ */
intrusive_ref_counter() BOOST_NOEXCEPT : m_ref_counter(0) intrusive_ref_counter() BOOST_SP_NOEXCEPT : m_ref_counter(0)
{ {
} }
@ -130,7 +131,7 @@ public:
* *
* \post <tt>use_count() == 0</tt> * \post <tt>use_count() == 0</tt>
*/ */
intrusive_ref_counter(intrusive_ref_counter const&) BOOST_NOEXCEPT : m_ref_counter(0) intrusive_ref_counter(intrusive_ref_counter const&) BOOST_SP_NOEXCEPT : m_ref_counter(0)
{ {
} }
@ -139,12 +140,12 @@ public:
* *
* \post The reference counter is not modified after assignment * \post The reference counter is not modified after assignment
*/ */
intrusive_ref_counter& operator= (intrusive_ref_counter const&) BOOST_NOEXCEPT { return *this; } intrusive_ref_counter& operator= (intrusive_ref_counter const&) BOOST_SP_NOEXCEPT { return *this; }
/*! /*!
* \return The reference counter * \return The reference counter
*/ */
unsigned int use_count() const BOOST_NOEXCEPT unsigned int use_count() const BOOST_SP_NOEXCEPT
{ {
return CounterPolicyT::load(m_ref_counter); return CounterPolicyT::load(m_ref_counter);
} }
@ -155,18 +156,18 @@ protected:
*/ */
BOOST_DEFAULTED_FUNCTION(~intrusive_ref_counter(), {}) BOOST_DEFAULTED_FUNCTION(~intrusive_ref_counter(), {})
friend void intrusive_ptr_add_ref< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT; friend void intrusive_ptr_add_ref< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
friend void intrusive_ptr_release< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT; friend void intrusive_ptr_release< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
}; };
template< typename DerivedT, typename CounterPolicyT > template< typename DerivedT, typename CounterPolicyT >
inline void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT inline void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT
{ {
CounterPolicyT::increment(p->m_ref_counter); CounterPolicyT::increment(p->m_ref_counter);
} }
template< typename DerivedT, typename CounterPolicyT > template< typename DerivedT, typename CounterPolicyT >
inline void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_NOEXCEPT inline void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT
{ {
if (CounterPolicyT::decrement(p->m_ref_counter) == 0) if (CounterPolicyT::decrement(p->m_ref_counter) == 0)
delete static_cast< const DerivedT* >(p); delete static_cast< const DerivedT* >(p);

View File

@ -50,7 +50,7 @@ public:
// destructor // destructor
~local_shared_ptr() ~local_shared_ptr() BOOST_SP_NOEXCEPT
{ {
if( pn ) if( pn )
{ {
@ -217,7 +217,7 @@ public:
// aliasing // aliasing
template<class Y> template<class Y>
local_shared_ptr( local_shared_ptr<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) local_shared_ptr( local_shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{ {
if( pn ) if( pn )
{ {
@ -228,7 +228,7 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> template<class Y>
local_shared_ptr( local_shared_ptr<Y> && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) local_shared_ptr( local_shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{ {
r.px = 0; r.px = 0;
r.pn = 0; r.pn = 0;
@ -313,14 +313,14 @@ public:
local_shared_ptr( p, d, a ).swap( *this ); local_shared_ptr( p, d, a ).swap( *this );
} }
template<class Y> void reset( local_shared_ptr<Y> const & r, element_type * p ) template<class Y> void reset( local_shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
{ {
local_shared_ptr( r, p ).swap( *this ); local_shared_ptr( r, p ).swap( *this );
} }
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> void reset( local_shared_ptr<Y> && r, element_type * p ) template<class Y> void reset( local_shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT
{ {
local_shared_ptr( std::move( r ), p ).swap( *this ); local_shared_ptr( std::move( r ), p ).swap( *this );
} }
@ -339,8 +339,7 @@ public:
return px; return px;
} }
// 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_SP_NOEXCEPT_WITH_ASSERT
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 ) );
@ -348,7 +347,7 @@ public:
return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] ); return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
} }
element_type * get() const BOOST_NOEXCEPT element_type * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
@ -523,7 +522,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< ( std:
template< class T > struct hash; template< class T > struct hash;
template< class T > std::size_t hash_value( local_shared_ptr<T> const & p ) BOOST_NOEXCEPT template< class T > std::size_t hash_value( local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return boost::hash< typename local_shared_ptr<T>::element_type* >()( p.get() ); return boost::hash< typename local_shared_ptr<T>::element_type* >()( p.get() );
} }

View File

@ -17,6 +17,7 @@
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_forward.hpp> #include <boost/smart_ptr/detail/sp_forward.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/type_traits/type_with_alignment.hpp> #include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/alignment_of.hpp>
#include <cstddef> #include <cstddef>
@ -48,7 +49,7 @@ private:
private: private:
void destroy() void destroy() BOOST_SP_NOEXCEPT
{ {
if( initialized_ ) if( initialized_ )
{ {
@ -70,39 +71,39 @@ private:
public: public:
sp_ms_deleter() BOOST_NOEXCEPT : initialized_( false ) sp_ms_deleter() BOOST_SP_NOEXCEPT : initialized_( false )
{ {
} }
template<class A> explicit sp_ms_deleter( A const & ) BOOST_NOEXCEPT : initialized_( false ) template<class A> explicit sp_ms_deleter( A const & ) BOOST_SP_NOEXCEPT : initialized_( false )
{ {
} }
// optimization: do not copy storage_ // optimization: do not copy storage_
sp_ms_deleter( sp_ms_deleter const & ) BOOST_NOEXCEPT : initialized_( false ) sp_ms_deleter( sp_ms_deleter const & ) BOOST_SP_NOEXCEPT : initialized_( false )
{ {
} }
~sp_ms_deleter() ~sp_ms_deleter() BOOST_SP_NOEXCEPT
{ {
destroy(); destroy();
} }
void operator()( T * ) void operator()( T * ) BOOST_SP_NOEXCEPT
{ {
destroy(); destroy();
} }
static void operator_fn( T* ) // operator() can't be static static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
{ {
} }
void * address() BOOST_NOEXCEPT void * address() BOOST_SP_NOEXCEPT
{ {
return storage_.data_; return storage_.data_;
} }
void set_initialized() BOOST_NOEXCEPT void set_initialized() BOOST_SP_NOEXCEPT
{ {
initialized_ = true; initialized_ = true;
} }
@ -120,7 +121,7 @@ private:
private: private:
void destroy() void destroy() BOOST_SP_NOEXCEPT
{ {
if( initialized_ ) if( initialized_ )
{ {
@ -142,35 +143,35 @@ private:
public: public:
sp_as_deleter( A const & a ) BOOST_NOEXCEPT : a_( a ), initialized_( false ) sp_as_deleter( A const & a ) BOOST_SP_NOEXCEPT : a_( a ), initialized_( false )
{ {
} }
// optimization: do not copy storage_ // optimization: do not copy storage_
sp_as_deleter( sp_as_deleter const & r ) BOOST_NOEXCEPT : a_( r.a_), initialized_( false ) sp_as_deleter( sp_as_deleter const & r ) BOOST_SP_NOEXCEPT : a_( r.a_), initialized_( false )
{ {
} }
~sp_as_deleter() ~sp_as_deleter() BOOST_SP_NOEXCEPT
{ {
destroy(); destroy();
} }
void operator()( T * ) void operator()( T * ) BOOST_SP_NOEXCEPT
{ {
destroy(); destroy();
} }
static void operator_fn( T* ) // operator() can't be static static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
{ {
} }
void * address() BOOST_NOEXCEPT void * address() BOOST_SP_NOEXCEPT
{ {
return storage_.data_; return storage_.data_;
} }
void set_initialized() BOOST_NOEXCEPT void set_initialized() BOOST_SP_NOEXCEPT
{ {
initialized_ = true; initialized_ = true;
} }

View File

@ -62,7 +62,7 @@ public:
#endif #endif
} }
~scoped_array() // never throws ~scoped_array() BOOST_SP_NOEXCEPT
{ {
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_array_destructor_hook( px ); boost::sp_array_destructor_hook( px );
@ -70,20 +70,20 @@ public:
boost::checked_array_delete( px ); boost::checked_array_delete( px );
} }
void reset(T * p = 0) // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) void reset(T * p = 0) BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
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 (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) T & operator[](std::ptrdiff_t i) const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
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 BOOST_NOEXCEPT T * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
@ -91,7 +91,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) BOOST_NOEXCEPT void swap(scoped_array & b) BOOST_SP_NOEXCEPT
{ {
T * tmp = b.px; T * tmp = b.px;
b.px = px; b.px = px;
@ -101,29 +101,29 @@ public:
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator==( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator!=( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator!=( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
#endif #endif
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_NOEXCEPT template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_SP_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }

View File

@ -63,7 +63,7 @@ public:
typedef T element_type; typedef T element_type;
explicit scoped_ptr( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p ) // never throws explicit scoped_ptr( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p )
{ {
#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 );
@ -72,7 +72,7 @@ public:
#ifndef BOOST_NO_AUTO_PTR #ifndef BOOST_NO_AUTO_PTR
explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_NOEXCEPT : px( p.release() ) explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_SP_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 );
@ -81,7 +81,7 @@ public:
#endif #endif
~scoped_ptr() // never throws ~scoped_ptr() BOOST_SP_NOEXCEPT
{ {
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_destructor_hook( px ); boost::sp_scalar_destructor_hook( px );
@ -89,25 +89,25 @@ public:
boost::checked_delete( px ); boost::checked_delete( px );
} }
void reset(T * p = 0) // never throws void reset(T * p = 0) BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
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*() const // never throws T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return *px; return *px;
} }
T * operator->() const // never throws T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return px; return px;
} }
T * get() const BOOST_NOEXCEPT T * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
@ -115,7 +115,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) BOOST_NOEXCEPT void swap(scoped_ptr & b) BOOST_SP_NOEXCEPT
{ {
T * tmp = b.px; T * tmp = b.px;
b.px = px; b.px = px;
@ -125,36 +125,36 @@ public:
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator==( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator!=( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator!=( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
#endif #endif
template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_NOEXCEPT template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_SP_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) BOOST_NOEXCEPT template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_SP_NOEXCEPT
{ {
return p.get(); return p.get();
} }

View File

@ -120,7 +120,7 @@ public:
shared_array( shared_array<Y> const & r ) shared_array( shared_array<Y> const & r )
#endif #endif
BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) // never throws BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
boost::detail::sp_assert_convertible< Y[], T[] >(); boost::detail::sp_assert_convertible< Y[], T[] >();
} }
@ -128,7 +128,7 @@ public:
// aliasing // aliasing
template< class Y > template< class Y >
shared_array( shared_array<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) shared_array( shared_array<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{ {
} }
@ -143,7 +143,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 ) BOOST_NOEXCEPT shared_array & operator=( shared_array<Y> const & r ) BOOST_SP_NOEXCEPT
{ {
this_type( r ).swap( *this ); this_type( r ).swap( *this );
return *this; return *this;
@ -160,7 +160,7 @@ public:
} }
template<class Y> template<class Y>
shared_array & operator=( shared_array<Y> && r ) BOOST_NOEXCEPT shared_array & operator=( shared_array<Y> && r ) BOOST_SP_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;
@ -168,7 +168,7 @@ public:
#endif #endif
void reset() BOOST_NOEXCEPT void reset() BOOST_SP_NOEXCEPT
{ {
this_type().swap( *this ); this_type().swap( *this );
} }
@ -189,19 +189,19 @@ public:
this_type( p, d, a ).swap( *this ); this_type( p, d, a ).swap( *this );
} }
template<class Y> void reset( shared_array<Y> const & r, element_type * p ) template<class Y> void reset( shared_array<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
{ {
this_type( r, p ).swap( *this ); this_type( r, p ).swap( *this );
} }
T & operator[] (std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) T & operator[] (std::ptrdiff_t i) const BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
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 BOOST_NOEXCEPT T * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
@ -209,23 +209,23 @@ 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 BOOST_NOEXCEPT bool unique() const BOOST_SP_NOEXCEPT
{ {
return pn.unique(); return pn.unique();
} }
long use_count() const BOOST_NOEXCEPT long use_count() const BOOST_SP_NOEXCEPT
{ {
return pn.use_count(); return pn.use_count();
} }
void swap(shared_array<T> & other) BOOST_NOEXCEPT void swap(shared_array<T> & other) BOOST_SP_NOEXCEPT
{ {
std::swap(px, other.px); std::swap(px, other.px);
pn.swap(other.pn); pn.swap(other.pn);
} }
void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_SP_NOEXCEPT
{ {
return pn.get_deleter( ti ); return pn.get_deleter( ti );
} }
@ -239,51 +239,51 @@ private:
}; // shared_array }; // shared_array
template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_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) BOOST_NOEXCEPT template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
#endif #endif
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_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) BOOST_NOEXCEPT template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_SP_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }
template< class D, class T > D * get_deleter( shared_array<T> const & p ) template< class D, class T > D * get_deleter( shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return static_cast< D * >( p._internal_get_deleter( BOOST_SP_TYPEID(D) ) ); return static_cast< D * >( p._internal_get_deleter( BOOST_SP_TYPEID(D) ) );
} }

View File

@ -262,7 +262,7 @@ template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R
// sp_assert_convertible // sp_assert_convertible
template< class Y, class T > inline void sp_assert_convertible() template< class Y, class T > inline void sp_assert_convertible() BOOST_SP_NOEXCEPT
{ {
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
@ -345,13 +345,13 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type; typedef typename boost::detail::sp_element< T >::type element_type;
shared_ptr() BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+ shared_ptr() BOOST_SP_NOEXCEPT : px( 0 ), pn()
{ {
} }
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
{ {
} }
@ -420,7 +420,7 @@ public:
template<class Y> template<class Y>
shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag ) shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag )
BOOST_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() ) BOOST_SP_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() )
{ {
if( !pn.empty() ) if( !pn.empty() )
{ {
@ -438,14 +438,14 @@ public:
shared_ptr( shared_ptr<Y> const & r ) shared_ptr( shared_ptr<Y> const & r )
#endif #endif
BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) BOOST_SP_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 ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) shared_ptr( shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{ {
} }
@ -531,7 +531,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) BOOST_NOEXCEPT shared_ptr & operator=(shared_ptr<Y> const & r) BOOST_SP_NOEXCEPT
{ {
this_type(r).swap(*this); this_type(r).swap(*this);
return *this; return *this;
@ -622,7 +622,7 @@ public:
shared_ptr( shared_ptr<Y> && r ) shared_ptr( shared_ptr<Y> && r )
#endif #endif
BOOST_NOEXCEPT : px( r.px ), pn() BOOST_SP_NOEXCEPT : px( r.px ), pn()
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
@ -637,7 +637,7 @@ public:
} }
template<class Y> template<class Y>
shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_NOEXCEPT shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_SP_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;
@ -645,7 +645,7 @@ public:
// aliasing move // aliasing move
template<class Y> template<class Y>
shared_ptr( shared_ptr<Y> && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn() shared_ptr( shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn()
{ {
pn.swap( r.pn ); pn.swap( r.pn );
r.px = 0; r.px = 0;
@ -655,7 +655,7 @@ public:
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT // never throws shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
this_type().swap(*this); this_type().swap(*this);
return *this; return *this;
@ -663,7 +663,7 @@ public:
#endif #endif
void reset() BOOST_NOEXCEPT // never throws in 1.30+ void reset() BOOST_SP_NOEXCEPT
{ {
this_type().swap(*this); this_type().swap(*this);
} }
@ -684,36 +684,33 @@ public:
this_type( p, d, a ).swap( *this ); this_type( p, d, a ).swap( *this );
} }
template<class Y> void reset( shared_ptr<Y> const & r, element_type * p ) template<class Y> void reset( shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
{ {
this_type( r, p ).swap( *this ); this_type( r, p ).swap( *this );
} }
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> void reset( shared_ptr<Y> && r, element_type * p ) template<class Y> void reset( shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT
{ {
this_type( static_cast< shared_ptr<Y> && >( r ), p ).swap( *this ); this_type( static_cast< shared_ptr<Y> && >( r ), p ).swap( *this );
} }
#endif #endif
// 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_SP_NOEXCEPT_WITH_ASSERT
typename boost::detail::sp_dereference< T >::type operator* () const
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return *px; return *px;
} }
// 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_SP_NOEXCEPT_WITH_ASSERT
typename boost::detail::sp_member_access< T >::type operator-> () const
{ {
BOOST_ASSERT( px != 0 ); BOOST_ASSERT( px != 0 );
return px; return px;
} }
// 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_SP_NOEXCEPT_WITH_ASSERT
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 ) );
@ -721,7 +718,7 @@ public:
return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] ); return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
} }
element_type * get() const BOOST_NOEXCEPT element_type * get() const BOOST_SP_NOEXCEPT
{ {
return px; return px;
} }
@ -729,43 +726,43 @@ 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 BOOST_NOEXCEPT bool unique() const BOOST_SP_NOEXCEPT
{ {
return pn.unique(); return pn.unique();
} }
long use_count() const BOOST_NOEXCEPT long use_count() const BOOST_SP_NOEXCEPT
{ {
return pn.use_count(); return pn.use_count();
} }
void swap( shared_ptr & other ) BOOST_NOEXCEPT void swap( shared_ptr & other ) BOOST_SP_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 BOOST_NOEXCEPT template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{ {
return pn < rhs.pn; return pn < rhs.pn;
} }
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{ {
return pn < rhs.pn; return pn < rhs.pn;
} }
void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_SP_NOEXCEPT
{ {
return pn.get_deleter( ti ); return pn.get_deleter( ti );
} }
void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT void * _internal_get_untyped_deleter() const BOOST_SP_NOEXCEPT
{ {
return pn.get_untyped_deleter(); return pn.get_untyped_deleter();
} }
bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT bool _internal_equiv( shared_ptr const & r ) const BOOST_SP_NOEXCEPT
{ {
return px == r.px && pn == r.pn; return px == r.px && pn == r.pn;
} }
@ -788,12 +785,12 @@ private:
}; // shared_ptr }; // shared_ptr
template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_SP_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) BOOST_NOEXCEPT template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
@ -802,7 +799,7 @@ 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) BOOST_NOEXCEPT template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) BOOST_SP_NOEXCEPT
{ {
return a.get() != b.get(); return a.get() != b.get();
} }
@ -811,39 +808,39 @@ template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T>
#if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() == 0; return p.get() == 0;
} }
template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return p.get() != 0; return p.get() != 0;
} }
#endif #endif
template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_SP_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) BOOST_NOEXCEPT template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) BOOST_SP_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }
template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{ {
(void) static_cast< T* >( static_cast< U* >( 0 ) ); (void) static_cast< T* >( static_cast< U* >( 0 ) );
@ -853,7 +850,7 @@ template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> cons
return shared_ptr<T>( r, p ); return shared_ptr<T>( r, p );
} }
template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{ {
(void) const_cast< T* >( static_cast< U* >( 0 ) ); (void) const_cast< T* >( static_cast< U* >( 0 ) );
@ -863,7 +860,7 @@ template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const
return shared_ptr<T>( r, p ); return shared_ptr<T>( r, p );
} }
template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{ {
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
@ -873,7 +870,7 @@ template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> con
return p? shared_ptr<T>( r, p ): shared_ptr<T>(); return p? shared_ptr<T>( r, p ): shared_ptr<T>();
} }
template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{ {
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@ -885,7 +882,7 @@ template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U>
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) static_cast< T* >( static_cast< U* >( 0 ) ); (void) static_cast< T* >( static_cast< U* >( 0 ) );
@ -895,7 +892,7 @@ template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> && r
return shared_ptr<T>( std::move(r), p ); return shared_ptr<T>( std::move(r), p );
} }
template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) const_cast< T* >( static_cast< U* >( 0 ) ); (void) const_cast< T* >( static_cast< U* >( 0 ) );
@ -905,7 +902,7 @@ template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> && r
return shared_ptr<T>( std::move(r), p ); return shared_ptr<T>( std::move(r), p );
} }
template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
@ -915,7 +912,7 @@ template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> &&
return p? shared_ptr<T>( std::move(r), p ): shared_ptr<T>(); return p? shared_ptr<T>( std::move(r), p ): shared_ptr<T>();
} }
template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{ {
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@ -929,7 +926,7 @@ template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U>
// get_pointer() enables boost::mem_fn to recognize shared_ptr // get_pointer() enables boost::mem_fn to recognize shared_ptr
template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_SP_NOEXCEPT
{ {
return p.get(); return p.get();
} }
@ -989,7 +986,7 @@ template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p)
#else #else
template<class D, class T> D * basic_get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT template<class D, class T> D * basic_get_deleter( shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return static_cast<D *>( p._internal_get_deleter(BOOST_SP_TYPEID(D)) ); return static_cast<D *>( p._internal_get_deleter(BOOST_SP_TYPEID(D)) );
} }
@ -1008,17 +1005,17 @@ public:
{ {
} }
template< class T > void set_deleter( shared_ptr<T> const & deleter ) template< class T > void set_deleter( shared_ptr<T> const & deleter ) BOOST_SP_NOEXCEPT
{ {
deleter_ = deleter; deleter_ = deleter;
} }
template<typename D> D* get_deleter() const BOOST_NOEXCEPT template<typename D> D* get_deleter() const BOOST_SP_NOEXCEPT
{ {
return boost::detail::basic_get_deleter<D>( deleter_ ); return boost::detail::basic_get_deleter<D>( deleter_ );
} }
template< class T> void operator()( T* ) template< class T> void operator()( T* ) BOOST_SP_NOEXCEPT_WITH_ASSERT
{ {
BOOST_ASSERT( deleter_.use_count() <= 1 ); BOOST_ASSERT( deleter_.use_count() <= 1 );
deleter_.reset(); deleter_.reset();
@ -1027,7 +1024,7 @@ public:
} // namespace detail } // namespace detail
template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
D *del = boost::detail::basic_get_deleter<D>(p); D *del = boost::detail::basic_get_deleter<D>(p);
@ -1046,34 +1043,34 @@ template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_NOEX
#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*/ ) BOOST_NOEXCEPT template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_SP_NOEXCEPT
{ {
return false; return false;
} }
template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) BOOST_SP_NOEXCEPT
{ {
boost::detail::spinlock_pool<2>::scoped_lock lock( p ); boost::detail::spinlock_pool<2>::scoped_lock lock( p );
return *p; return *p;
} }
template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
{ {
return atomic_load( p ); return atomic_load( p );
} }
template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{ {
boost::detail::spinlock_pool<2>::scoped_lock lock( p ); boost::detail::spinlock_pool<2>::scoped_lock lock( p );
p->swap( r ); p->swap( r );
} }
template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
{ {
atomic_store( p, r ); // std::move( r ) atomic_store( p, r ); // std::move( r )
} }
template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r ) template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{ {
boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p );
@ -1084,12 +1081,12 @@ template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T
return r; // return std::move( r ) return r; // return std::move( r )
} }
template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
{ {
return atomic_exchange( p, r ); // std::move( r ) return atomic_exchange( p, r ); // std::move( r )
} }
template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w ) template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w ) BOOST_SP_NOEXCEPT
{ {
boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p );
@ -1114,7 +1111,7 @@ template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T>
} }
} }
template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) BOOST_SP_NOEXCEPT
{ {
return atomic_compare_exchange( p, v, w ); // std::move( w ) return atomic_compare_exchange( p, v, w ); // std::move( w )
} }
@ -1125,7 +1122,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 ) BOOST_NOEXCEPT template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{ {
return boost::hash< typename boost::shared_ptr<T>::element_type* >()( p.get() ); return boost::hash< typename boost::shared_ptr<T>::element_type* >()( p.get() );
} }

View File

@ -32,7 +32,7 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type; typedef typename boost::detail::sp_element< T >::type element_type;
weak_ptr() BOOST_SP_NOEXCEPT : px(0), pn() // never throws in 1.30+ weak_ptr() BOOST_SP_NOEXCEPT : px(0), pn()
{ {
} }
@ -59,7 +59,7 @@ public:
// The "obvious" converting constructor implementation: // The "obvious" converting constructor implementation:
// //
// template<class Y> // template<class Y>
// weak_ptr(weak_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws // weak_ptr(weak_ptr<Y> const & r): px(r.px), pn(r.pn)
// { // {
// } // }
// //
@ -82,7 +82,7 @@ public:
weak_ptr( weak_ptr<Y> const & r ) weak_ptr( weak_ptr<Y> const & r )
#endif #endif
BOOST_NOEXCEPT : px(r.lock().get()), pn(r.pn) BOOST_SP_NOEXCEPT : px(r.lock().get()), pn(r.pn)
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
} }
@ -99,7 +99,7 @@ public:
weak_ptr( weak_ptr<Y> && r ) weak_ptr( weak_ptr<Y> && r )
#endif #endif
BOOST_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) BOOST_SP_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;
@ -132,7 +132,7 @@ public:
weak_ptr( shared_ptr<Y> const & r ) weak_ptr( shared_ptr<Y> const & r )
#endif #endif
BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
} }
@ -140,7 +140,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 ) BOOST_NOEXCEPT weak_ptr & operator=( weak_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
@ -153,7 +153,7 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> template<class Y>
weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_NOEXCEPT weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_SP_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;
@ -162,7 +162,7 @@ public:
#endif #endif
template<class Y> template<class Y>
weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_NOEXCEPT weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
{ {
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
@ -174,50 +174,50 @@ public:
#endif #endif
shared_ptr<T> lock() const BOOST_NOEXCEPT shared_ptr<T> lock() const BOOST_SP_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 BOOST_NOEXCEPT long use_count() const BOOST_SP_NOEXCEPT
{ {
return pn.use_count(); return pn.use_count();
} }
bool expired() const BOOST_NOEXCEPT bool expired() const BOOST_SP_NOEXCEPT
{ {
return pn.use_count() == 0; return pn.use_count() == 0;
} }
bool _empty() const // extension, not in std::weak_ptr bool _empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
{ {
return pn.empty(); return pn.empty();
} }
void reset() BOOST_NOEXCEPT // never throws in 1.30+ void reset() BOOST_SP_NOEXCEPT
{ {
this_type().swap(*this); this_type().swap(*this);
} }
void swap(this_type & other) BOOST_NOEXCEPT void swap(this_type & other) BOOST_SP_NOEXCEPT
{ {
std::swap(px, other.px); std::swap(px, other.px);
pn.swap(other.pn); pn.swap(other.pn);
} }
template<typename Y> template<typename Y>
void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2) void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2) BOOST_SP_NOEXCEPT
{ {
px = px2; px = px2;
pn = r.pn; pn = r.pn;
} }
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{ {
return pn < rhs.pn; return pn < rhs.pn;
} }
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{ {
return pn < rhs.pn; return pn < rhs.pn;
} }
@ -239,12 +239,12 @@ private:
}; // weak_ptr }; // weak_ptr
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_NOEXCEPT template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_SP_NOEXCEPT
{ {
return a.owner_before( b ); return a.owner_before( b );
} }
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_NOEXCEPT template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_SP_NOEXCEPT
{ {
a.swap(b); a.swap(b);
} }