From 52d976fde28d4ce25a6c42001db3e0460f07a4dc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 12 Jun 2017 18:06:54 +0300 Subject: [PATCH] Use BOOST_SP_NOEXCEPT, BOOST_SP_NOEXCEPT_WITH_ASSERT --- include/boost/pointer_cast.hpp | 19 +-- .../boost/smart_ptr/allocate_shared_array.hpp | 67 +++++----- .../smart_ptr/detail/local_counted_base.hpp | 4 +- .../boost/smart_ptr/detail/operator_bool.hpp | 12 +- .../boost/smart_ptr/detail/sp_noexcept.hpp | 24 +++- .../smart_ptr/enable_shared_from_this.hpp | 6 +- include/boost/smart_ptr/intrusive_ptr.hpp | 44 +++---- .../boost/smart_ptr/intrusive_ref_counter.hpp | 33 ++--- include/boost/smart_ptr/local_shared_ptr.hpp | 17 ++- .../boost/smart_ptr/make_shared_object.hpp | 35 ++--- include/boost/smart_ptr/scoped_array.hpp | 20 +-- include/boost/smart_ptr/scoped_ptr.hpp | 28 ++-- include/boost/smart_ptr/shared_array.hpp | 42 +++--- include/boost/smart_ptr/shared_ptr.hpp | 121 +++++++++--------- include/boost/smart_ptr/weak_ptr.hpp | 38 +++--- 15 files changed, 264 insertions(+), 246 deletions(-) diff --git a/include/boost/pointer_cast.hpp b/include/boost/pointer_cast.hpp index 5af4971..d47327b 100644 --- a/include/boost/pointer_cast.hpp +++ b/include/boost/pointer_cast.hpp @@ -11,33 +11,34 @@ #define BOOST_POINTER_CAST_HPP #include +#include namespace boost { //static_pointer_cast overload for raw pointers template -inline T* static_pointer_cast(U *ptr) +inline T* static_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT { return static_cast(ptr); } //dynamic_pointer_cast overload for raw pointers template -inline T* dynamic_pointer_cast(U *ptr) +inline T* dynamic_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT { return dynamic_cast(ptr); } //const_pointer_cast overload for raw pointers template -inline T* const_pointer_cast(U *ptr) +inline T* const_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT { return const_cast(ptr); } //reinterpret_pointer_cast overload for raw pointers template -inline T* reinterpret_pointer_cast(U *ptr) +inline T* reinterpret_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT { return reinterpret_cast(ptr); } @@ -62,7 +63,7 @@ using std::dynamic_pointer_cast; using std::const_pointer_cast; //reinterpret_pointer_cast overload for std::shared_ptr -template std::shared_ptr reinterpret_pointer_cast(const std::shared_ptr & r ) BOOST_NOEXCEPT +template std::shared_ptr reinterpret_pointer_cast(const std::shared_ptr & r ) BOOST_SP_NOEXCEPT { (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); @@ -73,7 +74,7 @@ template std::shared_ptr reinterpret_pointer_cast(const std } //static_pointer_cast overload for std::unique_ptr -template std::unique_ptr static_pointer_cast( std::unique_ptr && r ) BOOST_NOEXCEPT +template std::unique_ptr static_pointer_cast( std::unique_ptr && r ) BOOST_SP_NOEXCEPT { (void) static_cast< T* >( static_cast< U* >( 0 ) ); @@ -83,7 +84,7 @@ template std::unique_ptr static_pointer_cast( std::unique_p } //dynamic_pointer_cast overload for std::unique_ptr -template std::unique_ptr dynamic_pointer_cast( std::unique_ptr && r ) BOOST_NOEXCEPT +template std::unique_ptr dynamic_pointer_cast( std::unique_ptr && r ) BOOST_SP_NOEXCEPT { (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); @@ -95,7 +96,7 @@ template std::unique_ptr dynamic_pointer_cast( std::unique_ } //const_pointer_cast overload for std::unique_ptr -template std::unique_ptr const_pointer_cast( std::unique_ptr && r ) BOOST_NOEXCEPT +template std::unique_ptr const_pointer_cast( std::unique_ptr && r ) BOOST_SP_NOEXCEPT { (void) const_cast< T* >( static_cast< U* >( 0 ) ); @@ -105,7 +106,7 @@ template std::unique_ptr const_pointer_cast( std::unique_pt } //reinterpret_pointer_cast overload for std::unique_ptr -template std::unique_ptr reinterpret_pointer_cast( std::unique_ptr && r ) BOOST_NOEXCEPT +template std::unique_ptr reinterpret_pointer_cast( std::unique_ptr && r ) BOOST_SP_NOEXCEPT { (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp index 6dca68f..636340c 100644 --- a/include/boost/smart_ptr/allocate_shared_array.hpp +++ b/include/boost/smart_ptr/allocate_shared_array.hpp @@ -9,6 +9,7 @@ Distributed under the Boost Software License, Version 1.0. #define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP #include +#include #include #include #include @@ -111,7 +112,7 @@ struct sp_array_count { }; template inline D* -sp_get_deleter(const boost::shared_ptr& value) BOOST_NOEXCEPT_OR_NOTHROW +sp_get_deleter(const boost::shared_ptr& value) BOOST_SP_NOEXCEPT { return static_cast(value._internal_get_untyped_deleter()); } @@ -153,7 +154,7 @@ struct sp_enable { template inline typename sp_enable::value>::type -sp_array_destroy(T*, std::size_t) BOOST_NOEXCEPT { } +sp_array_destroy(T*, std::size_t) BOOST_SP_NOEXCEPT { } template inline typename sp_enable::value>::type @@ -308,7 +309,7 @@ sp_array_construct(A& allocator, T* storage, std::size_t size, template inline typename sp_enable::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) template @@ -357,7 +358,7 @@ struct sp_less_align { template BOOST_CONSTEXPR inline typename sp_enable::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); } @@ -365,14 +366,14 @@ sp_align(std::size_t size) BOOST_NOEXCEPT template BOOST_CONSTEXPR inline typename sp_enable::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; } template 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); } @@ -381,16 +382,16 @@ template class sp_size_array_deleter { public: template - 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) { } template - sp_size_array_deleter(const A&) BOOST_NOEXCEPT + sp_size_array_deleter(const A&) BOOST_SP_NOEXCEPT : 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) { } ~sp_size_array_deleter() { @@ -436,15 +437,15 @@ template class sp_size_array_destroyer { public: template - static void operator_fn(U) BOOST_NOEXCEPT { } + static void operator_fn(U) BOOST_SP_NOEXCEPT { } template - sp_size_array_destroyer(const U& allocator) BOOST_NOEXCEPT + sp_size_array_destroyer(const U& allocator) BOOST_SP_NOEXCEPT : allocator_(allocator), enabled_(false) { } sp_size_array_destroyer(const sp_size_array_destroyer& other) - BOOST_NOEXCEPT + BOOST_SP_NOEXCEPT : allocator_(other.allocator_), enabled_(false) { } @@ -475,7 +476,7 @@ public: return &storage_; } - const A& allocator() const BOOST_NOEXCEPT { + const A& allocator() const BOOST_SP_NOEXCEPT { return allocator_; } @@ -491,23 +492,23 @@ template class sp_array_deleter { public: template - 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), size_(size) { } template - sp_array_deleter(const A& allocator) BOOST_NOEXCEPT + sp_array_deleter(const A& allocator) BOOST_SP_NOEXCEPT : address_(0), size_(allocator.size()) { } template - 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), 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), size_(other.size_) { } @@ -540,7 +541,7 @@ public: address_ = address; } - std::size_t size() const BOOST_NOEXCEPT { + std::size_t size() const BOOST_SP_NOEXCEPT { return size_; } @@ -554,21 +555,21 @@ template class sp_array_destroyer { public: template - static void operator_fn(U) BOOST_NOEXCEPT { } + static void operator_fn(U) BOOST_SP_NOEXCEPT { } template - 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), size_(size), address_(0) { } template - sp_array_destroyer(const U& allocator) BOOST_NOEXCEPT + sp_array_destroyer(const U& allocator) BOOST_SP_NOEXCEPT : allocator_(allocator.allocator()), size_(allocator.size()), 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_), size_(other.size_), address_(0) { } @@ -597,11 +598,11 @@ public: address_ = address; } - const A& allocator() const BOOST_NOEXCEPT { + const A& allocator() const BOOST_SP_NOEXCEPT { return allocator_; } - std::size_t size() const BOOST_NOEXCEPT { + std::size_t size() const BOOST_SP_NOEXCEPT { return size_; } @@ -637,17 +638,17 @@ public: }; sp_array_allocator(const A& allocator, std::size_t size, void** result) - BOOST_NOEXCEPT + BOOST_SP_NOEXCEPT : allocator_(allocator), size_(size), 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), size_(size) { } template - sp_array_allocator(const sp_array_allocator& other) BOOST_NOEXCEPT + sp_array_allocator(const sp_array_allocator& other) BOOST_SP_NOEXCEPT : allocator_(other.allocator_), size_(other.size_), result_(other.result_) { } @@ -668,11 +669,11 @@ public: allocator.deallocate(reinterpret_cast(value), size); } - const A& allocator() const BOOST_NOEXCEPT { + const A& allocator() const BOOST_SP_NOEXCEPT { return allocator_; } - std::size_t size() const BOOST_NOEXCEPT { + std::size_t size() const BOOST_SP_NOEXCEPT { return size_; } @@ -685,7 +686,7 @@ private: template inline bool operator==(const sp_array_allocator& first, - const sp_array_allocator& second) BOOST_NOEXCEPT + const sp_array_allocator& second) BOOST_SP_NOEXCEPT { return first.allocator() == second.allocator() && first.size() == second.size(); @@ -694,7 +695,7 @@ operator==(const sp_array_allocator& first, template inline bool operator!=(const sp_array_allocator& first, - const sp_array_allocator& second) BOOST_NOEXCEPT + const sp_array_allocator& second) BOOST_SP_NOEXCEPT { return !(first == second); } diff --git a/include/boost/smart_ptr/detail/local_counted_base.hpp b/include/boost/smart_ptr/detail/local_counted_base.hpp index 46408c3..94a9b02 100644 --- a/include/boost/smart_ptr/detail/local_counted_base.hpp +++ b/include/boost/smart_ptr/detail/local_counted_base.hpp @@ -44,7 +44,7 @@ private: 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_; } diff --git a/include/boost/smart_ptr/detail/operator_bool.hpp b/include/boost/smart_ptr/detail/operator_bool.hpp index c0289b8..f9c5ef6 100644 --- a/include/boost/smart_ptr/detail/operator_bool.hpp +++ b/include/boost/smart_ptr/detail/operator_bool.hpp @@ -9,14 +9,14 @@ #if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\ && !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) - explicit operator bool () const BOOST_NOEXCEPT + explicit operator bool () const BOOST_SP_NOEXCEPT { return px != 0; } #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; } @@ -29,7 +29,7 @@ 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; } @@ -41,7 +41,7 @@ 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; } @@ -50,7 +50,7 @@ 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; } @@ -58,7 +58,7 @@ #endif // operator! is redundant, but some compilers need it - bool operator! () const BOOST_NOEXCEPT + bool operator! () const BOOST_SP_NOEXCEPT { return px == 0; } diff --git a/include/boost/smart_ptr/detail/sp_noexcept.hpp b/include/boost/smart_ptr/detail/sp_noexcept.hpp index 6818dce..1287ba4 100644 --- a/include/boost/smart_ptr/detail/sp_noexcept.hpp +++ b/include/boost/smart_ptr/detail/sp_noexcept.hpp @@ -9,7 +9,7 @@ // detail/sp_noexcept.hpp // -// Copyright 2016 Peter Dimov +// Copyright 2016, 2017 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -17,13 +17,31 @@ #include +// BOOST_SP_NOEXCEPT + #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 -#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 diff --git a/include/boost/smart_ptr/enable_shared_from_this.hpp b/include/boost/smart_ptr/enable_shared_from_this.hpp index 642403a..2e16f81 100644 --- a/include/boost/smart_ptr/enable_shared_from_this.hpp +++ b/include/boost/smart_ptr/enable_shared_from_this.hpp @@ -59,12 +59,12 @@ public: return p; } - weak_ptr weak_from_this() BOOST_NOEXCEPT + weak_ptr weak_from_this() BOOST_SP_NOEXCEPT { return weak_this_; } - weak_ptr weak_from_this() const BOOST_NOEXCEPT + weak_ptr weak_from_this() const BOOST_SP_NOEXCEPT { return weak_this_; } @@ -72,7 +72,7 @@ public: public: // actually private, but avoids compiler template friendship issues // Note: invoked automatically by shared_ptr; do not call - template void _internal_accept_owner( shared_ptr const * ppx, Y * py ) const + template void _internal_accept_owner( shared_ptr const * ppx, Y * py ) const BOOST_SP_NOEXCEPT { if( weak_this_.expired() ) { diff --git a/include/boost/smart_ptr/intrusive_ptr.hpp b/include/boost/smart_ptr/intrusive_ptr.hpp index 0e46212..aaf4e1e 100644 --- a/include/boost/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/smart_ptr/intrusive_ptr.hpp @@ -141,7 +141,7 @@ public: } template - intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_NOEXCEPT + intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT { this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); return *this; @@ -161,7 +161,7 @@ public: return *this; } - void reset() BOOST_NOEXCEPT + void reset() { this_type().swap( *this ); } @@ -176,25 +176,25 @@ public: this_type( rhs, add_ref ).swap( *this ); } - T * get() const BOOST_NOEXCEPT + T * get() const BOOST_SP_NOEXCEPT { return px; } - T * detach() BOOST_NOEXCEPT + T * detach() BOOST_SP_NOEXCEPT { T * ret = px; px = 0; return ret; } - T & operator*() const + T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); return *px; } - T * operator->() const + T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); return px; @@ -203,7 +203,7 @@ public: // implicit conversion to "bool" #include - void swap(intrusive_ptr & rhs) BOOST_NOEXCEPT + void swap(intrusive_ptr & rhs) BOOST_SP_NOEXCEPT { T * tmp = px; px = rhs.px; @@ -215,32 +215,32 @@ private: T * px; }; -template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) +template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() == b.get(); } -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) +template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() != b.get(); } -template inline bool operator==(intrusive_ptr const & a, U * b) +template inline bool operator==(intrusive_ptr const & a, U * b) BOOST_SP_NOEXCEPT { return a.get() == b; } -template inline bool operator!=(intrusive_ptr const & a, U * b) +template inline bool operator!=(intrusive_ptr const & a, U * b) BOOST_SP_NOEXCEPT { return a.get() != b; } -template inline bool operator==(T * a, intrusive_ptr const & b) +template inline bool operator==(T * a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return a == b.get(); } -template inline bool operator!=(T * a, intrusive_ptr const & b) +template inline bool operator!=(T * a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return a != b.get(); } @@ -249,7 +249,7 @@ template inline bool operator!=(T * a, intrusive_ptr const // Resolve the ambiguity between our op!= and the one in rel_ops -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) +template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() != b.get(); } @@ -258,41 +258,41 @@ template inline bool operator!=(intrusive_ptr const & a, intrusive_p #if !defined( BOOST_NO_CXX11_NULLPTR ) -template inline bool operator==( intrusive_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator==( intrusive_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator!=( intrusive_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator!=( intrusive_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() != 0; } -template inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() != 0; } #endif -template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) +template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) BOOST_SP_NOEXCEPT { return std::less()(a.get(), b.get()); } -template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs) +template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs) BOOST_SP_NOEXCEPT { lhs.swap(rhs); } // mem_fn support -template T * get_pointer(intrusive_ptr const & p) +template T * get_pointer(intrusive_ptr const & p) BOOST_SP_NOEXCEPT { return p.get(); } @@ -351,7 +351,7 @@ template std::basic_ostream & operator<< (std:: template< class T > struct hash; -template< class T > std::size_t hash_value( boost::intrusive_ptr const & p ) +template< class T > std::size_t hash_value( boost::intrusive_ptr const & p ) BOOST_SP_NOEXCEPT { return boost::hash< T* >()( p.get() ); } diff --git a/include/boost/smart_ptr/intrusive_ref_counter.hpp b/include/boost/smart_ptr/intrusive_ref_counter.hpp index b7587ea..c2f918d 100644 --- a/include/boost/smart_ptr/intrusive_ref_counter.hpp +++ b/include/boost/smart_ptr/intrusive_ref_counter.hpp @@ -17,6 +17,7 @@ #include #include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -45,17 +46,17 @@ struct thread_unsafe_counter { 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; } - static void increment(unsigned int& counter) BOOST_NOEXCEPT + static void increment(unsigned int& counter) BOOST_SP_NOEXCEPT { ++counter; } - static unsigned int decrement(unsigned int& counter) BOOST_NOEXCEPT + static unsigned int decrement(unsigned int& counter) BOOST_SP_NOEXCEPT { return --counter; } @@ -71,17 +72,17 @@ struct thread_safe_counter { 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)); } - static void increment(boost::detail::atomic_count& counter) BOOST_NOEXCEPT + static void increment(boost::detail::atomic_count& counter) BOOST_SP_NOEXCEPT { ++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); } @@ -91,9 +92,9 @@ template< typename DerivedT, typename CounterPolicyT = thread_safe_counter > class intrusive_ref_counter; 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 > -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 @@ -121,7 +122,7 @@ public: * * \post use_count() == 0 */ - 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 use_count() == 0 */ - 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 */ - 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 */ - unsigned int use_count() const BOOST_NOEXCEPT + unsigned int use_count() const BOOST_SP_NOEXCEPT { return CounterPolicyT::load(m_ref_counter); } @@ -155,18 +156,18 @@ protected: */ 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_release< 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_SP_NOEXCEPT; }; 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); } 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) delete static_cast< const DerivedT* >(p); diff --git a/include/boost/smart_ptr/local_shared_ptr.hpp b/include/boost/smart_ptr/local_shared_ptr.hpp index 0f42550..dcf2128 100644 --- a/include/boost/smart_ptr/local_shared_ptr.hpp +++ b/include/boost/smart_ptr/local_shared_ptr.hpp @@ -50,7 +50,7 @@ public: // destructor - ~local_shared_ptr() + ~local_shared_ptr() BOOST_SP_NOEXCEPT { if( pn ) { @@ -217,7 +217,7 @@ public: // aliasing template - local_shared_ptr( local_shared_ptr const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + local_shared_ptr( local_shared_ptr const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn ) { if( pn ) { @@ -228,7 +228,7 @@ public: #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template - local_shared_ptr( local_shared_ptr && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + local_shared_ptr( local_shared_ptr && r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn ) { r.px = 0; r.pn = 0; @@ -313,14 +313,14 @@ public: local_shared_ptr( p, d, a ).swap( *this ); } - template void reset( local_shared_ptr const & r, element_type * p ) + template void reset( local_shared_ptr const & r, element_type * p ) BOOST_SP_NOEXCEPT { local_shared_ptr( r, p ).swap( *this ); } #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - template void reset( local_shared_ptr && r, element_type * p ) + template void reset( local_shared_ptr && r, element_type * p ) BOOST_SP_NOEXCEPT { local_shared_ptr( std::move( r ), p ).swap( *this ); } @@ -339,8 +339,7 @@ public: 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 + typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 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 ] ); } - element_type * get() const BOOST_NOEXCEPT + element_type * get() const BOOST_SP_NOEXCEPT { return px; } @@ -523,7 +522,7 @@ template std::basic_ostream & operator<< ( std: template< class T > struct hash; -template< class T > std::size_t hash_value( local_shared_ptr const & p ) BOOST_NOEXCEPT +template< class T > std::size_t hash_value( local_shared_ptr const & p ) BOOST_SP_NOEXCEPT { return boost::hash< typename local_shared_ptr::element_type* >()( p.get() ); } diff --git a/include/boost/smart_ptr/make_shared_object.hpp b/include/boost/smart_ptr/make_shared_object.hpp index 3bc78ee..59172e1 100644 --- a/include/boost/smart_ptr/make_shared_object.hpp +++ b/include/boost/smart_ptr/make_shared_object.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ private: private: - void destroy() + void destroy() BOOST_SP_NOEXCEPT { if( initialized_ ) { @@ -70,39 +71,39 @@ private: public: - sp_ms_deleter() BOOST_NOEXCEPT : initialized_( false ) + sp_ms_deleter() BOOST_SP_NOEXCEPT : initialized_( false ) { } - template explicit sp_ms_deleter( A const & ) BOOST_NOEXCEPT : initialized_( false ) + template explicit sp_ms_deleter( A const & ) BOOST_SP_NOEXCEPT : initialized_( false ) { } // 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(); } - void operator()( T * ) + void operator()( T * ) BOOST_SP_NOEXCEPT { 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_; } - void set_initialized() BOOST_NOEXCEPT + void set_initialized() BOOST_SP_NOEXCEPT { initialized_ = true; } @@ -120,7 +121,7 @@ private: private: - void destroy() + void destroy() BOOST_SP_NOEXCEPT { if( initialized_ ) { @@ -142,35 +143,35 @@ private: 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_ - 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(); } - void operator()( T * ) + void operator()( T * ) BOOST_SP_NOEXCEPT { 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_; } - void set_initialized() BOOST_NOEXCEPT + void set_initialized() BOOST_SP_NOEXCEPT { initialized_ = true; } diff --git a/include/boost/smart_ptr/scoped_array.hpp b/include/boost/smart_ptr/scoped_array.hpp index f847c09..5cd4b40 100644 --- a/include/boost/smart_ptr/scoped_array.hpp +++ b/include/boost/smart_ptr/scoped_array.hpp @@ -62,7 +62,7 @@ public: #endif } - ~scoped_array() // never throws + ~scoped_array() BOOST_SP_NOEXCEPT { #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) boost::sp_array_destructor_hook( px ); @@ -70,20 +70,20 @@ public: 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 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( i >= 0 ); return px[i]; } - T * get() const BOOST_NOEXCEPT + T * get() const BOOST_SP_NOEXCEPT { return px; } @@ -91,7 +91,7 @@ public: // implicit conversion to "bool" #include - void swap(scoped_array & b) BOOST_NOEXCEPT + void swap(scoped_array & b) BOOST_SP_NOEXCEPT { T * tmp = b.px; b.px = px; @@ -101,29 +101,29 @@ public: #if !defined( BOOST_NO_CXX11_NULLPTR ) -template inline bool operator==( scoped_array const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator==( scoped_array const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator==( boost::detail::sp_nullptr_t, scoped_array const & p ) BOOST_NOEXCEPT +template inline bool operator==( boost::detail::sp_nullptr_t, scoped_array const & p ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator!=( scoped_array const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator!=( scoped_array const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() != 0; } -template inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array const & p ) BOOST_NOEXCEPT +template inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array const & p ) BOOST_SP_NOEXCEPT { return p.get() != 0; } #endif -template inline void swap(scoped_array & a, scoped_array & b) BOOST_NOEXCEPT +template inline void swap(scoped_array & a, scoped_array & b) BOOST_SP_NOEXCEPT { a.swap(b); } diff --git a/include/boost/smart_ptr/scoped_ptr.hpp b/include/boost/smart_ptr/scoped_ptr.hpp index 8fd8a18..5e290b2 100644 --- a/include/boost/smart_ptr/scoped_ptr.hpp +++ b/include/boost/smart_ptr/scoped_ptr.hpp @@ -63,7 +63,7 @@ public: 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) boost::sp_scalar_constructor_hook( px ); @@ -72,7 +72,7 @@ public: #ifndef BOOST_NO_AUTO_PTR - explicit scoped_ptr( std::auto_ptr p ) BOOST_NOEXCEPT : px( p.release() ) + explicit scoped_ptr( std::auto_ptr p ) BOOST_SP_NOEXCEPT : px( p.release() ) { #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) boost::sp_scalar_constructor_hook( px ); @@ -81,7 +81,7 @@ public: #endif - ~scoped_ptr() // never throws + ~scoped_ptr() BOOST_SP_NOEXCEPT { #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) boost::sp_scalar_destructor_hook( px ); @@ -89,25 +89,25 @@ public: 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 this_type(p).swap(*this); } - T & operator*() const // never throws + T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); return *px; } - T * operator->() const // never throws + T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); return px; } - T * get() const BOOST_NOEXCEPT + T * get() const BOOST_SP_NOEXCEPT { return px; } @@ -115,7 +115,7 @@ public: // implicit conversion to "bool" #include - void swap(scoped_ptr & b) BOOST_NOEXCEPT + void swap(scoped_ptr & b) BOOST_SP_NOEXCEPT { T * tmp = b.px; b.px = px; @@ -125,36 +125,36 @@ public: #if !defined( BOOST_NO_CXX11_NULLPTR ) -template inline bool operator==( scoped_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator==( scoped_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator!=( scoped_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator!=( scoped_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() != 0; } -template inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() != 0; } #endif -template inline void swap(scoped_ptr & a, scoped_ptr & b) BOOST_NOEXCEPT +template inline void swap(scoped_ptr & a, scoped_ptr & b) BOOST_SP_NOEXCEPT { a.swap(b); } // get_pointer(p) is a generic way to say p.get() -template inline T * get_pointer(scoped_ptr const & p) BOOST_NOEXCEPT +template inline T * get_pointer(scoped_ptr const & p) BOOST_SP_NOEXCEPT { return p.get(); } diff --git a/include/boost/smart_ptr/shared_array.hpp b/include/boost/smart_ptr/shared_array.hpp index 2e5cb13..8e856cf 100644 --- a/include/boost/smart_ptr/shared_array.hpp +++ b/include/boost/smart_ptr/shared_array.hpp @@ -120,7 +120,7 @@ public: shared_array( shared_array const & r ) #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[] >(); } @@ -128,7 +128,7 @@ public: // aliasing template< class Y > - shared_array( shared_array const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + shared_array( shared_array 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) template - shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT + shared_array & operator=( shared_array const & r ) BOOST_SP_NOEXCEPT { this_type( r ).swap( *this ); return *this; @@ -160,7 +160,7 @@ public: } template - shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT + shared_array & operator=( shared_array && r ) BOOST_SP_NOEXCEPT { this_type( static_cast< shared_array && >( r ) ).swap( *this ); return *this; @@ -168,7 +168,7 @@ public: #endif - void reset() BOOST_NOEXCEPT + void reset() BOOST_SP_NOEXCEPT { this_type().swap( *this ); } @@ -189,19 +189,19 @@ public: this_type( p, d, a ).swap( *this ); } - template void reset( shared_array const & r, element_type * p ) + template void reset( shared_array const & r, element_type * p ) BOOST_SP_NOEXCEPT { 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(i >= 0); return px[i]; } - T * get() const BOOST_NOEXCEPT + T * get() const BOOST_SP_NOEXCEPT { return px; } @@ -209,23 +209,23 @@ public: // implicit conversion to "bool" #include - bool unique() const BOOST_NOEXCEPT + bool unique() const BOOST_SP_NOEXCEPT { return pn.unique(); } - long use_count() const BOOST_NOEXCEPT + long use_count() const BOOST_SP_NOEXCEPT { return pn.use_count(); } - void swap(shared_array & other) BOOST_NOEXCEPT + void swap(shared_array & other) BOOST_SP_NOEXCEPT { std::swap(px, other.px); 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 ); } @@ -239,51 +239,51 @@ private: }; // shared_array -template inline bool operator==(shared_array const & a, shared_array const & b) BOOST_NOEXCEPT +template inline bool operator==(shared_array const & a, shared_array const & b) BOOST_SP_NOEXCEPT { return a.get() == b.get(); } -template inline bool operator!=(shared_array const & a, shared_array const & b) BOOST_NOEXCEPT +template inline bool operator!=(shared_array const & a, shared_array const & b) BOOST_SP_NOEXCEPT { return a.get() != b.get(); } #if !defined( BOOST_NO_CXX11_NULLPTR ) -template inline bool operator==( shared_array const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator==( shared_array const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator==( boost::detail::sp_nullptr_t, shared_array const & p ) BOOST_NOEXCEPT +template inline bool operator==( boost::detail::sp_nullptr_t, shared_array const & p ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator!=( shared_array const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator!=( shared_array const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() != 0; } -template inline bool operator!=( boost::detail::sp_nullptr_t, shared_array const & p ) BOOST_NOEXCEPT +template inline bool operator!=( boost::detail::sp_nullptr_t, shared_array const & p ) BOOST_SP_NOEXCEPT { return p.get() != 0; } #endif -template inline bool operator<(shared_array const & a, shared_array const & b) BOOST_NOEXCEPT +template inline bool operator<(shared_array const & a, shared_array const & b) BOOST_SP_NOEXCEPT { return std::less()(a.get(), b.get()); } -template void swap(shared_array & a, shared_array & b) BOOST_NOEXCEPT +template void swap(shared_array & a, shared_array & b) BOOST_SP_NOEXCEPT { a.swap(b); } -template< class D, class T > D * get_deleter( shared_array const & p ) +template< class D, class T > D * get_deleter( shared_array const & p ) BOOST_SP_NOEXCEPT { return static_cast< D * >( p._internal_get_deleter( BOOST_SP_TYPEID(D) ) ); } diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp index e33707b..a9e3807 100644 --- a/include/boost/smart_ptr/shared_ptr.hpp +++ b/include/boost/smart_ptr/shared_ptr.hpp @@ -262,7 +262,7 @@ template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R // 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 ) @@ -345,13 +345,13 @@ public: 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 ) - 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 shared_ptr( weak_ptr 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() ) { @@ -438,14 +438,14 @@ public: shared_ptr( shared_ptr const & r ) #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 >(); } // aliasing template< class Y > - shared_ptr( shared_ptr const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + shared_ptr( shared_ptr 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) template - shared_ptr & operator=(shared_ptr const & r) BOOST_NOEXCEPT + shared_ptr & operator=(shared_ptr const & r) BOOST_SP_NOEXCEPT { this_type(r).swap(*this); return *this; @@ -622,7 +622,7 @@ public: shared_ptr( shared_ptr && r ) #endif - BOOST_NOEXCEPT : px( r.px ), pn() + BOOST_SP_NOEXCEPT : px( r.px ), pn() { boost::detail::sp_assert_convertible< Y, T >(); @@ -637,7 +637,7 @@ public: } template - shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT + shared_ptr & operator=( shared_ptr && r ) BOOST_SP_NOEXCEPT { this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; @@ -645,7 +645,7 @@ public: // aliasing move template - shared_ptr( shared_ptr && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn() + shared_ptr( shared_ptr && r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn() { pn.swap( r.pn ); r.px = 0; @@ -655,7 +655,7 @@ public: #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); return *this; @@ -663,7 +663,7 @@ public: #endif - void reset() BOOST_NOEXCEPT // never throws in 1.30+ + void reset() BOOST_SP_NOEXCEPT { this_type().swap(*this); } @@ -684,36 +684,33 @@ public: this_type( p, d, a ).swap( *this ); } - template void reset( shared_ptr const & r, element_type * p ) + template void reset( shared_ptr const & r, element_type * p ) BOOST_SP_NOEXCEPT { this_type( r, p ).swap( *this ); } #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - template void reset( shared_ptr && r, element_type * p ) + template void reset( shared_ptr && r, element_type * p ) BOOST_SP_NOEXCEPT { this_type( static_cast< shared_ptr && >( r ), p ).swap( *this ); } #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 + typename boost::detail::sp_dereference< T >::type operator* () const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); 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 + typename boost::detail::sp_member_access< T >::type operator-> () const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 0 ); 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 + typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( px != 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 ] ); } - element_type * get() const BOOST_NOEXCEPT + element_type * get() const BOOST_SP_NOEXCEPT { return px; } @@ -729,43 +726,43 @@ public: // implicit conversion to "bool" #include - bool unique() const BOOST_NOEXCEPT + bool unique() const BOOST_SP_NOEXCEPT { return pn.unique(); } - long use_count() const BOOST_NOEXCEPT + long use_count() const BOOST_SP_NOEXCEPT { return pn.use_count(); } - void swap( shared_ptr & other ) BOOST_NOEXCEPT + void swap( shared_ptr & other ) BOOST_SP_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } - template bool owner_before( shared_ptr const & rhs ) const BOOST_NOEXCEPT + template bool owner_before( shared_ptr const & rhs ) const BOOST_SP_NOEXCEPT { return pn < rhs.pn; } - template bool owner_before( weak_ptr const & rhs ) const BOOST_NOEXCEPT + template bool owner_before( weak_ptr const & rhs ) const BOOST_SP_NOEXCEPT { 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 ); } - void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT + void * _internal_get_untyped_deleter() const BOOST_SP_NOEXCEPT { 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; } @@ -788,12 +785,12 @@ private: }; // shared_ptr -template inline bool operator==(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT +template inline bool operator==(shared_ptr const & a, shared_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() == b.get(); } -template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT +template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() != b.get(); } @@ -802,7 +799,7 @@ template inline bool operator!=(shared_ptr const & a, share // Resolve the ambiguity between our op!= and the one in rel_ops -template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT +template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_SP_NOEXCEPT { return a.get() != b.get(); } @@ -811,39 +808,39 @@ template inline bool operator!=(shared_ptr const & a, shared_ptr #if !defined( BOOST_NO_CXX11_NULLPTR ) -template inline bool operator==( shared_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator==( shared_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() == 0; } -template inline bool operator!=( shared_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +template inline bool operator!=( shared_ptr const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT { return p.get() != 0; } -template inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_NOEXCEPT +template inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_SP_NOEXCEPT { return p.get() != 0; } #endif -template inline bool operator<(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT +template inline bool operator<(shared_ptr const & a, shared_ptr const & b) BOOST_SP_NOEXCEPT { return a.owner_before( b ); } -template inline void swap(shared_ptr & a, shared_ptr & b) BOOST_NOEXCEPT +template inline void swap(shared_ptr & a, shared_ptr & b) BOOST_SP_NOEXCEPT { a.swap(b); } -template shared_ptr static_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT +template shared_ptr static_pointer_cast( shared_ptr const & r ) BOOST_SP_NOEXCEPT { (void) static_cast< T* >( static_cast< U* >( 0 ) ); @@ -853,7 +850,7 @@ template shared_ptr static_pointer_cast( shared_ptr cons return shared_ptr( r, p ); } -template shared_ptr const_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT +template shared_ptr const_pointer_cast( shared_ptr const & r ) BOOST_SP_NOEXCEPT { (void) const_cast< T* >( static_cast< U* >( 0 ) ); @@ -863,7 +860,7 @@ template shared_ptr const_pointer_cast( shared_ptr const return shared_ptr( r, p ); } -template shared_ptr dynamic_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT +template shared_ptr dynamic_pointer_cast( shared_ptr const & r ) BOOST_SP_NOEXCEPT { (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); @@ -873,7 +870,7 @@ template shared_ptr dynamic_pointer_cast( shared_ptr con return p? shared_ptr( r, p ): shared_ptr(); } -template shared_ptr reinterpret_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT +template shared_ptr reinterpret_pointer_cast( shared_ptr const & r ) BOOST_SP_NOEXCEPT { (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); @@ -885,7 +882,7 @@ template shared_ptr reinterpret_pointer_cast( shared_ptr #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) -template shared_ptr static_pointer_cast( shared_ptr && r ) BOOST_NOEXCEPT +template shared_ptr static_pointer_cast( shared_ptr && r ) BOOST_SP_NOEXCEPT { (void) static_cast< T* >( static_cast< U* >( 0 ) ); @@ -895,7 +892,7 @@ template shared_ptr static_pointer_cast( shared_ptr && r return shared_ptr( std::move(r), p ); } -template shared_ptr const_pointer_cast( shared_ptr && r ) BOOST_NOEXCEPT +template shared_ptr const_pointer_cast( shared_ptr && r ) BOOST_SP_NOEXCEPT { (void) const_cast< T* >( static_cast< U* >( 0 ) ); @@ -905,7 +902,7 @@ template shared_ptr const_pointer_cast( shared_ptr && r return shared_ptr( std::move(r), p ); } -template shared_ptr dynamic_pointer_cast( shared_ptr && r ) BOOST_NOEXCEPT +template shared_ptr dynamic_pointer_cast( shared_ptr && r ) BOOST_SP_NOEXCEPT { (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); @@ -915,7 +912,7 @@ template shared_ptr dynamic_pointer_cast( shared_ptr && return p? shared_ptr( std::move(r), p ): shared_ptr(); } -template shared_ptr reinterpret_pointer_cast( shared_ptr && r ) BOOST_NOEXCEPT +template shared_ptr reinterpret_pointer_cast( shared_ptr && r ) BOOST_SP_NOEXCEPT { (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); @@ -929,7 +926,7 @@ template shared_ptr reinterpret_pointer_cast( shared_ptr // get_pointer() enables boost::mem_fn to recognize shared_ptr -template inline typename shared_ptr::element_type * get_pointer(shared_ptr const & p) BOOST_NOEXCEPT +template inline typename shared_ptr::element_type * get_pointer(shared_ptr const & p) BOOST_SP_NOEXCEPT { return p.get(); } @@ -989,7 +986,7 @@ template D * basic_get_deleter(shared_ptr const & p) #else -template D * basic_get_deleter( shared_ptr const & p ) BOOST_NOEXCEPT +template D * basic_get_deleter( shared_ptr const & p ) BOOST_SP_NOEXCEPT { return static_cast( p._internal_get_deleter(BOOST_SP_TYPEID(D)) ); } @@ -1008,17 +1005,17 @@ public: { } - template< class T > void set_deleter( shared_ptr const & deleter ) + template< class T > void set_deleter( shared_ptr const & deleter ) BOOST_SP_NOEXCEPT { deleter_ = deleter; } - template D* get_deleter() const BOOST_NOEXCEPT + template D* get_deleter() const BOOST_SP_NOEXCEPT { return boost::detail::basic_get_deleter( deleter_ ); } - template< class T> void operator()( T* ) + template< class T> void operator()( T* ) BOOST_SP_NOEXCEPT_WITH_ASSERT { BOOST_ASSERT( deleter_.use_count() <= 1 ); deleter_.reset(); @@ -1027,7 +1024,7 @@ public: } // namespace detail -template D * get_deleter( shared_ptr const & p ) BOOST_NOEXCEPT +template D * get_deleter( shared_ptr const & p ) BOOST_SP_NOEXCEPT { D *del = boost::detail::basic_get_deleter(p); @@ -1046,34 +1043,34 @@ template D * get_deleter( shared_ptr const & p ) BOOST_NOEX #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) -template inline bool atomic_is_lock_free( shared_ptr const * /*p*/ ) BOOST_NOEXCEPT +template inline bool atomic_is_lock_free( shared_ptr const * /*p*/ ) BOOST_SP_NOEXCEPT { return false; } -template shared_ptr atomic_load( shared_ptr const * p ) +template shared_ptr atomic_load( shared_ptr const * p ) BOOST_SP_NOEXCEPT { boost::detail::spinlock_pool<2>::scoped_lock lock( p ); return *p; } -template inline shared_ptr atomic_load_explicit( shared_ptr const * p, /*memory_order mo*/ int ) +template inline shared_ptr atomic_load_explicit( shared_ptr const * p, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT { return atomic_load( p ); } -template void atomic_store( shared_ptr * p, shared_ptr r ) +template void atomic_store( shared_ptr * p, shared_ptr r ) BOOST_SP_NOEXCEPT { boost::detail::spinlock_pool<2>::scoped_lock lock( p ); p->swap( r ); } -template inline void atomic_store_explicit( shared_ptr * p, shared_ptr r, /*memory_order mo*/ int ) +template inline void atomic_store_explicit( shared_ptr * p, shared_ptr r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT { atomic_store( p, r ); // std::move( r ) } -template shared_ptr atomic_exchange( shared_ptr * p, shared_ptr r ) +template shared_ptr atomic_exchange( shared_ptr * p, shared_ptr r ) BOOST_SP_NOEXCEPT { boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); @@ -1084,12 +1081,12 @@ template shared_ptr atomic_exchange( shared_ptr * p, shared_ptr shared_ptr atomic_exchange_explicit( shared_ptr * p, shared_ptr r, /*memory_order mo*/ int ) +template shared_ptr atomic_exchange_explicit( shared_ptr * p, shared_ptr r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT { return atomic_exchange( p, r ); // std::move( r ) } -template bool atomic_compare_exchange( shared_ptr * p, shared_ptr * v, shared_ptr w ) +template bool atomic_compare_exchange( shared_ptr * p, shared_ptr * v, shared_ptr w ) BOOST_SP_NOEXCEPT { boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); @@ -1114,7 +1111,7 @@ template bool atomic_compare_exchange( shared_ptr * p, shared_ptr } } -template inline bool atomic_compare_exchange_explicit( shared_ptr * p, shared_ptr * v, shared_ptr w, /*memory_order success*/ int, /*memory_order failure*/ int ) +template inline bool atomic_compare_exchange_explicit( shared_ptr * p, shared_ptr * v, shared_ptr w, /*memory_order success*/ int, /*memory_order failure*/ int ) BOOST_SP_NOEXCEPT { return atomic_compare_exchange( p, v, w ); // std::move( w ) } @@ -1125,7 +1122,7 @@ template inline bool atomic_compare_exchange_explicit( shared_ptr * template< class T > struct hash; -template< class T > std::size_t hash_value( boost::shared_ptr const & p ) BOOST_NOEXCEPT +template< class T > std::size_t hash_value( boost::shared_ptr const & p ) BOOST_SP_NOEXCEPT { return boost::hash< typename boost::shared_ptr::element_type* >()( p.get() ); } diff --git a/include/boost/smart_ptr/weak_ptr.hpp b/include/boost/smart_ptr/weak_ptr.hpp index f3411f7..cd0da7a 100644 --- a/include/boost/smart_ptr/weak_ptr.hpp +++ b/include/boost/smart_ptr/weak_ptr.hpp @@ -32,7 +32,7 @@ public: 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: // // template -// weak_ptr(weak_ptr const & r): px(r.px), pn(r.pn) // never throws +// weak_ptr(weak_ptr const & r): px(r.px), pn(r.pn) // { // } // @@ -82,7 +82,7 @@ public: weak_ptr( weak_ptr const & r ) #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 >(); } @@ -99,7 +99,7 @@ public: weak_ptr( weak_ptr && r ) #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 >(); r.px = 0; @@ -132,7 +132,7 @@ public: weak_ptr( shared_ptr const & r ) #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 >(); } @@ -140,7 +140,7 @@ public: #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) template - weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT + weak_ptr & operator=( weak_ptr const & r ) BOOST_SP_NOEXCEPT { boost::detail::sp_assert_convertible< Y, T >(); @@ -153,7 +153,7 @@ public: #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template - weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT + weak_ptr & operator=( weak_ptr && r ) BOOST_SP_NOEXCEPT { this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; @@ -162,7 +162,7 @@ public: #endif template - weak_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT + weak_ptr & operator=( shared_ptr const & r ) BOOST_SP_NOEXCEPT { boost::detail::sp_assert_convertible< Y, T >(); @@ -174,50 +174,50 @@ public: #endif - shared_ptr lock() const BOOST_NOEXCEPT + shared_ptr lock() const BOOST_SP_NOEXCEPT { return shared_ptr( *this, boost::detail::sp_nothrow_tag() ); } - long use_count() const BOOST_NOEXCEPT + long use_count() const BOOST_SP_NOEXCEPT { return pn.use_count(); } - bool expired() const BOOST_NOEXCEPT + bool expired() const BOOST_SP_NOEXCEPT { 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(); } - void reset() BOOST_NOEXCEPT // never throws in 1.30+ + void reset() BOOST_SP_NOEXCEPT { this_type().swap(*this); } - void swap(this_type & other) BOOST_NOEXCEPT + void swap(this_type & other) BOOST_SP_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } template - void _internal_aliasing_assign(weak_ptr const & r, element_type * px2) + void _internal_aliasing_assign(weak_ptr const & r, element_type * px2) BOOST_SP_NOEXCEPT { px = px2; pn = r.pn; } - template bool owner_before( weak_ptr const & rhs ) const BOOST_NOEXCEPT + template bool owner_before( weak_ptr const & rhs ) const BOOST_SP_NOEXCEPT { return pn < rhs.pn; } - template bool owner_before( shared_ptr const & rhs ) const BOOST_NOEXCEPT + template bool owner_before( shared_ptr const & rhs ) const BOOST_SP_NOEXCEPT { return pn < rhs.pn; } @@ -239,12 +239,12 @@ private: }; // weak_ptr -template inline bool operator<(weak_ptr const & a, weak_ptr const & b) BOOST_NOEXCEPT +template inline bool operator<(weak_ptr const & a, weak_ptr const & b) BOOST_SP_NOEXCEPT { return a.owner_before( b ); } -template void swap(weak_ptr & a, weak_ptr & b) BOOST_NOEXCEPT +template void swap(weak_ptr & a, weak_ptr & b) BOOST_SP_NOEXCEPT { a.swap(b); }