diff options
Diffstat (limited to 'boost/smart_ptr/detail')
28 files changed, 346 insertions, 25 deletions
diff --git a/boost/smart_ptr/detail/atomic_count_gcc.hpp b/boost/smart_ptr/detail/atomic_count_gcc.hpp index 54807e944e..df7e32365f 100644 --- a/boost/smart_ptr/detail/atomic_count_gcc.hpp +++ b/boost/smart_ptr/detail/atomic_count_gcc.hpp @@ -9,7 +9,7 @@ // http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org> +// Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org> // Copyright 2003-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See diff --git a/boost/smart_ptr/detail/local_counted_base.hpp b/boost/smart_ptr/detail/local_counted_base.hpp new file mode 100644 index 0000000000..398b46dd1a --- /dev/null +++ b/boost/smart_ptr/detail/local_counted_base.hpp @@ -0,0 +1,146 @@ +#ifndef BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/local_counted_base.hpp +// +// Copyright 2017 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/smart_ptr/ for documentation. + +#include <boost/smart_ptr/detail/shared_count.hpp> +#include <boost/config.hpp> +#include <utility> + +namespace boost +{ + +namespace detail +{ + +class local_counted_base +{ +private: + + local_counted_base & operator= ( local_counted_base const & ); + +private: + + // not 'int' or 'unsigned' to avoid aliasing and enable optimizations + enum count_type { min_ = 0, initial_ = 1, max_ = 2147483647 }; + + count_type local_use_count_; + +public: + + BOOST_CONSTEXPR local_counted_base() BOOST_SP_NOEXCEPT: local_use_count_( initial_ ) + { + } + + BOOST_CONSTEXPR local_counted_base( local_counted_base const & ) BOOST_SP_NOEXCEPT: local_use_count_( initial_ ) + { + } + + virtual ~local_counted_base() /*BOOST_SP_NOEXCEPT*/ + { + } + + virtual void local_cb_destroy() BOOST_SP_NOEXCEPT = 0; + + virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT = 0; + + void add_ref() BOOST_SP_NOEXCEPT + { +#if defined( __has_builtin ) +# if __has_builtin( __builtin_assume ) + + __builtin_assume( local_use_count_ >= 1 ); + +# endif +#endif + + local_use_count_ = static_cast<count_type>( local_use_count_ + 1 ); + } + + void release() BOOST_SP_NOEXCEPT + { + local_use_count_ = static_cast<count_type>( local_use_count_ - 1 ); + + if( local_use_count_ == 0 ) + { + local_cb_destroy(); + } + } + + long local_use_count() const BOOST_SP_NOEXCEPT + { + return local_use_count_; + } +}; + +class local_counted_impl: public local_counted_base +{ +private: + + local_counted_impl( local_counted_impl const & ); + +private: + + shared_count pn_; + +public: + + explicit local_counted_impl( shared_count const& pn ): pn_( pn ) + { + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + explicit local_counted_impl( shared_count && pn ): pn_( std::move(pn) ) + { + } + +#endif + + virtual void local_cb_destroy() BOOST_SP_NOEXCEPT + { + delete this; + } + + virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT + { + return pn_; + } +}; + +class local_counted_impl_em: public local_counted_base +{ +public: + + shared_count pn_; + + virtual void local_cb_destroy() BOOST_SP_NOEXCEPT + { + shared_count().swap( pn_ ); + } + + virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT + { + return pn_; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED diff --git a/boost/smart_ptr/detail/local_sp_deleter.hpp b/boost/smart_ptr/detail/local_sp_deleter.hpp new file mode 100644 index 0000000000..7d04f1dc52 --- /dev/null +++ b/boost/smart_ptr/detail/local_sp_deleter.hpp @@ -0,0 +1,91 @@ +#ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/local_sp_deleter.hpp +// +// Copyright 2017 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/smart_ptr/ for documentation. + +#include <boost/smart_ptr/detail/local_counted_base.hpp> +#include <boost/config.hpp> + +namespace boost +{ + +namespace detail +{ + +template<class D> class local_sp_deleter: public local_counted_impl_em +{ +private: + + D d_; + +public: + + local_sp_deleter(): d_() + { + } + + explicit local_sp_deleter( D const& d ) BOOST_SP_NOEXCEPT: d_( d ) + { + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + explicit local_sp_deleter( D&& d ) BOOST_SP_NOEXCEPT: d_( std::move(d) ) + { + } + +#endif + + D& deleter() + { + return d_; + } + + template<class Y> void operator()( Y* p ) BOOST_SP_NOEXCEPT + { + d_( p ); + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT + { + d_( p ); + } + +#endif +}; + +template<> class local_sp_deleter<void> +{ +}; + +template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) +{ + return &p->deleter(); +} + +inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) +{ + return 0; +} + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED diff --git a/boost/smart_ptr/detail/lwm_win32_cs.hpp b/boost/smart_ptr/detail/lwm_win32_cs.hpp index a93cf09208..7d3e156166 100644 --- a/boost/smart_ptr/detail/lwm_win32_cs.hpp +++ b/boost/smart_ptr/detail/lwm_win32_cs.hpp @@ -21,7 +21,13 @@ #include <boost/predef.h> #ifdef BOOST_USE_WINDOWS_H -# include <windows.h> + +#include <windows.h> + +#else + +struct _RTL_CRITICAL_SECTION; + #endif namespace boost @@ -47,13 +53,13 @@ struct critical_section }; #if BOOST_PLAT_WINDOWS_RUNTIME -extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(critical_section *, unsigned long, unsigned long); +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(::_RTL_CRITICAL_SECTION *, unsigned long, unsigned long); #else -extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *); +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *); #endif -extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *); -extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *); -extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *); +extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *); +extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *); +extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *); #else @@ -75,15 +81,15 @@ public: lightweight_mutex() { #if BOOST_PLAT_WINDOWS_RUNTIME - InitializeCriticalSectionEx(&cs_, 4000, 0); + boost::detail::InitializeCriticalSectionEx(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_), 4000, 0); #else - InitializeCriticalSection(&cs_); + boost::detail::InitializeCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); #endif } ~lightweight_mutex() { - DeleteCriticalSection(&cs_); + boost::detail::DeleteCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); } class scoped_lock; @@ -102,12 +108,12 @@ public: explicit scoped_lock(lightweight_mutex & m): m_(m) { - EnterCriticalSection(&m_.cs_); + boost::detail::EnterCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); } ~scoped_lock() { - LeaveCriticalSection(&m_.cs_); + boost::detail::LeaveCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); } }; }; diff --git a/boost/smart_ptr/detail/operator_bool.hpp b/boost/smart_ptr/detail/operator_bool.hpp index c0289b870b..f9c5ef6803 100644 --- a/boost/smart_ptr/detail/operator_bool.hpp +++ b/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/boost/smart_ptr/detail/shared_count.hpp b/boost/smart_ptr/detail/shared_count.hpp index 9813842300..ae7d0fb46f 100644 --- a/boost/smart_ptr/detail/shared_count.hpp +++ b/boost/smart_ptr/detail/shared_count.hpp @@ -54,7 +54,7 @@ namespace boost namespace movelib { - template< class T, class D > class unique_ptr; +template< class T, class D > class unique_ptr; } // namespace movelib @@ -118,7 +118,14 @@ private: public: - shared_count(): pi_(0) // nothrow + BOOST_CONSTEXPR shared_count(): pi_(0) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + } + + BOOST_CONSTEXPR explicit shared_count( sp_counted_base * pi ): pi_( pi ) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(shared_count_id) #endif @@ -496,6 +503,11 @@ public: return pi_? pi_->get_deleter( ti ): 0; } + void * get_local_deleter( sp_typeinfo const & ti ) const + { + return pi_? pi_->get_local_deleter( ti ): 0; + } + void * get_untyped_deleter() const { return pi_? pi_->get_untyped_deleter(): 0; @@ -517,7 +529,7 @@ private: public: - weak_count(): pi_(0) // nothrow + BOOST_CONSTEXPR weak_count(): pi_(0) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(weak_count_id) #endif diff --git a/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp b/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp index cebc243d2e..ec6f6ee184 100644 --- a/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_aix.hpp b/boost/smart_ptr/detail/sp_counted_base_aix.hpp index fe6c727e38..ce8ee686ba 100644 --- a/boost/smart_ptr/detail/sp_counted_base_aix.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_aix.hpp @@ -96,6 +96,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_clang.hpp b/boost/smart_ptr/detail/sp_counted_base_clang.hpp index 75984959d3..8b3bfad9b6 100644 --- a/boost/smart_ptr/detail/sp_counted_base_clang.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_clang.hpp @@ -98,6 +98,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp b/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp index 6c268e8921..065f7c3d14 100644 --- a/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp @@ -124,6 +124,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp b/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp index 81eba6f178..3a3d4d4119 100644 --- a/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp @@ -112,6 +112,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp index f6e3904157..6c3cce8d44 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp @@ -111,6 +111,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp index 545c8ae4fc..76ac2a612d 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp index 2e5bc0e853..0fb807488a 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp index c6d20ce7ea..b8bb707f1b 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp @@ -120,6 +120,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp index 173dce5c81..3d2dd61ed6 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp @@ -127,6 +127,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_nt.hpp b/boost/smart_ptr/detail/sp_counted_base_nt.hpp index 5c901f9d16..dea905c905 100644 --- a/boost/smart_ptr/detail/sp_counted_base_nt.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_nt.hpp @@ -59,6 +59,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_pt.hpp b/boost/smart_ptr/detail/sp_counted_base_pt.hpp index a16d2d8652..85f2563d5d 100644 --- a/boost/smart_ptr/detail/sp_counted_base_pt.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_pt.hpp @@ -71,6 +71,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp b/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp index 56ed79fa97..7b5f9178a6 100644 --- a/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp @@ -115,6 +115,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_solaris.hpp b/boost/smart_ptr/detail/sp_counted_base_solaris.hpp index 0e05fef4cb..0db9c6cbd5 100644 --- a/boost/smart_ptr/detail/sp_counted_base_solaris.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_solaris.hpp @@ -62,6 +62,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_spin.hpp b/boost/smart_ptr/detail/sp_counted_base_spin.hpp index 77734e727d..faf503ad57 100644 --- a/boost/smart_ptr/detail/sp_counted_base_spin.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_spin.hpp @@ -84,6 +84,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp b/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp index cab8453591..7a188f8a66 100644 --- a/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp @@ -90,6 +90,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_sync.hpp b/boost/smart_ptr/detail/sp_counted_base_sync.hpp index fafed0e72e..d2138e7c26 100644 --- a/boost/smart_ptr/detail/sp_counted_base_sync.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_sync.hpp @@ -109,6 +109,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp b/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp index 162f309b56..f2de3b02d8 100644 --- a/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_base_w32.hpp b/boost/smart_ptr/detail/sp_counted_base_w32.hpp index 4ba509c6cd..960e42e128 100644 --- a/boost/smart_ptr/detail/sp_counted_base_w32.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_w32.hpp @@ -67,6 +67,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0; virtual void * get_untyped_deleter() = 0; void add_ref_copy() diff --git a/boost/smart_ptr/detail/sp_counted_impl.hpp b/boost/smart_ptr/detail/sp_counted_impl.hpp index b29769e3af..fa2f75eb1a 100644 --- a/boost/smart_ptr/detail/sp_counted_impl.hpp +++ b/boost/smart_ptr/detail/sp_counted_impl.hpp @@ -26,6 +26,7 @@ #include <boost/checked_delete.hpp> #include <boost/smart_ptr/detail/sp_counted_base.hpp> +#include <boost/core/addressof.hpp> #if defined(BOOST_SP_USE_QUICK_ALLOCATOR) #include <boost/smart_ptr/detail/quick_allocator.hpp> @@ -50,6 +51,19 @@ void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn ); namespace detail { +// get_local_deleter + +template<class D> class local_sp_deleter; + +template<class D> D * get_local_deleter( D * /*p*/ ) +{ + return 0; +} + +template<class D> D * get_local_deleter( local_sp_deleter<D> * p ); + +// + template<class X> class sp_counted_impl_p: public sp_counted_base { private: @@ -83,6 +97,11 @@ public: return 0; } + virtual void * get_local_deleter( sp_typeinfo const & ) + { + return 0; + } + virtual void * get_untyped_deleter() { return 0; @@ -158,6 +177,11 @@ public: return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0; } + virtual void * get_local_deleter( sp_typeinfo const & ti ) + { + return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( boost::addressof( del ) ): 0; + } + virtual void * get_untyped_deleter() { return &reinterpret_cast<char&>( del ); @@ -246,6 +270,11 @@ public: return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0; } + virtual void * get_local_deleter( sp_typeinfo const & ti ) + { + return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( boost::addressof( d_ ) ): 0; + } + virtual void * get_untyped_deleter() { return &reinterpret_cast<char&>( d_ ); diff --git a/boost/smart_ptr/detail/sp_noexcept.hpp b/boost/smart_ptr/detail/sp_noexcept.hpp index 6818dce38d..1287ba4952 100644 --- a/boost/smart_ptr/detail/sp_noexcept.hpp +++ b/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/config.hpp> +// 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 + +#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 BOOST_NOEXCEPT +# define BOOST_SP_NOEXCEPT_WITH_ASSERT BOOST_SP_NOEXCEPT #endif diff --git a/boost/smart_ptr/detail/yield_k.hpp b/boost/smart_ptr/detail/yield_k.hpp index 44d1836478..f8ca6b6467 100644 --- a/boost/smart_ptr/detail/yield_k.hpp +++ b/boost/smart_ptr/detail/yield_k.hpp @@ -33,7 +33,7 @@ // BOOST_SMT_PAUSE -#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) +#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) && !defined(__c2__) extern "C" void _mm_pause(); |