From dccecc2500360fe4bd31da71f5e21e933da1d3c5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 25 Sep 2024 03:13:22 +0300 Subject: [PATCH] Remove uses of BOOST_NO_CXX11_ALLOCATOR --- .../boost/smart_ptr/detail/shared_count.hpp | 16 ---------- .../smart_ptr/detail/sp_counted_impl.hpp | 8 ----- .../smart_ptr/make_local_shared_object.hpp | 32 ------------------- .../boost/smart_ptr/make_shared_object.hpp | 26 --------------- test/allocate_shared_alloc11_test.cpp | 11 ------- test/allocate_shared_array_construct_test.cpp | 11 ++----- test/allocate_shared_construct11_test.cpp | 13 +------- test/shared_ptr_alloc11_test.cpp | 13 +------- test/shared_ptr_alloc_construct11_test.cpp | 9 +----- 9 files changed, 5 insertions(+), 134 deletions(-) diff --git a/include/boost/smart_ptr/detail/shared_count.hpp b/include/boost/smart_ptr/detail/shared_count.hpp index 2d6d8e8..09daf90 100644 --- a/include/boost/smart_ptr/detail/shared_count.hpp +++ b/include/boost/smart_ptr/detail/shared_count.hpp @@ -231,16 +231,8 @@ public: { typedef sp_counted_impl_pda impl_type; -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc< impl_type > A2; -#else - - typedef typename A::template rebind< impl_type >::other A2; - -#endif - A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS @@ -286,16 +278,8 @@ public: { typedef sp_counted_impl_pda< P, D, A > impl_type; -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc< impl_type > A2; -#else - - typedef typename A::template rebind< impl_type >::other A2; - -#endif - A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS diff --git a/include/boost/smart_ptr/detail/sp_counted_impl.hpp b/include/boost/smart_ptr/detail/sp_counted_impl.hpp index 3c3d9f0..bb3c70f 100644 --- a/include/boost/smart_ptr/detail/sp_counted_impl.hpp +++ b/include/boost/smart_ptr/detail/sp_counted_impl.hpp @@ -238,16 +238,8 @@ public: void destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE { -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc< this_type > A2; -#else - - typedef typename A::template rebind< this_type >::other A2; - -#endif - A2 a2( a_ ); this->~this_type(); diff --git a/include/boost/smart_ptr/make_local_shared_object.hpp b/include/boost/smart_ptr/make_local_shared_object.hpp index 4545c5e..aca931f 100644 --- a/include/boost/smart_ptr/make_local_shared_object.hpp +++ b/include/boost/smart_ptr/make_local_shared_object.hpp @@ -59,16 +59,8 @@ private: { T * p = reinterpret_cast< T* >( storage_.data_ ); -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - std::allocator_traits::destroy( a_, p ); -#else - - p->~T(); - -#endif - initialized_ = false; } } @@ -113,16 +105,8 @@ public: template typename boost::detail::lsp_if_not_array::type allocate_local_shared( A const & a, Args&&... args ) { -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc A2; -#else - - typedef typename A::template rebind::other A2; - -#endif - A2 a2( a ); typedef boost::detail::lsp_ms_deleter D; @@ -132,16 +116,8 @@ template typename boost::detail::lsp_if_not_arr D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() ); void * pv = pd->address(); -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - std::allocator_traits::construct( a2, static_cast< T* >( pv ), std::forward( args )... ); -#else - - ::new( pv ) T( std::forward( args )... ); - -#endif - pd->set_initialized(); T * pt2 = static_cast< T* >( pv ); @@ -154,16 +130,8 @@ template typename boost::detail::lsp_if_not_arr template typename boost::detail::lsp_if_not_array::type allocate_local_shared_noinit( A const & a ) { -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc A2; -#else - - typedef typename A::template rebind::other A2; - -#endif - A2 a2( a ); typedef boost::detail::lsp_ms_deleter< T, std::allocator > D; diff --git a/include/boost/smart_ptr/make_shared_object.hpp b/include/boost/smart_ptr/make_shared_object.hpp index 52709bc..99e89d1 100644 --- a/include/boost/smart_ptr/make_shared_object.hpp +++ b/include/boost/smart_ptr/make_shared_object.hpp @@ -124,16 +124,8 @@ private: { T * p = reinterpret_cast< T* >( storage_.data_ ); -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - std::allocator_traits::destroy( a_, p ); -#else - - p->~T(); - -#endif - initialized_ = false; } } @@ -248,8 +240,6 @@ template< class T, class... Args > typename boost::detail::sp_if_not_array< T >: template< class T, class A, class... Args > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, Args && ... args ) { -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - typedef typename std::allocator_traits::template rebind_alloc A2; A2 a2( a ); @@ -257,27 +247,11 @@ template< class T, class A, class... Args > typename boost::detail::sp_if_not_ar boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag(), a2 ); -#else - - typedef boost::detail::sp_ms_deleter< T > D; - - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag(), a ); - -#endif - D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() ); void * pv = pd->address(); -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - std::allocator_traits::construct( a2, static_cast< T* >( pv ), std::forward( args )... ); -#else - - ::new( pv ) T( std::forward( args )... ); - -#endif - pd->set_initialized(); T * pt2 = static_cast< T* >( pv ); diff --git a/test/allocate_shared_alloc11_test.cpp b/test/allocate_shared_alloc11_test.cpp index db63b95..8df1ec0 100644 --- a/test/allocate_shared_alloc11_test.cpp +++ b/test/allocate_shared_alloc11_test.cpp @@ -15,8 +15,6 @@ #include #include -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - template< class T > class cxx11_allocator { public: @@ -230,12 +228,3 @@ int main() return boost::report_errors(); } - -#else // !defined( BOOST_NO_CXX11_ALLOCATOR ) - -int main() -{ - return 0; -} - -#endif diff --git a/test/allocate_shared_array_construct_test.cpp b/test/allocate_shared_array_construct_test.cpp index ef0dc95..0b5a2f0 100644 --- a/test/allocate_shared_array_construct_test.cpp +++ b/test/allocate_shared_array_construct_test.cpp @@ -5,10 +5,9 @@ Copyright 2012-2015 Glen Joseph Fernandes Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ -#include -#if !defined(BOOST_NO_CXX11_ALLOCATOR) -#include #include +#include +#include struct allow { }; @@ -155,9 +154,3 @@ int main() } return boost::report_errors(); } -#else -int main() -{ - return 0; -} -#endif diff --git a/test/allocate_shared_construct11_test.cpp b/test/allocate_shared_construct11_test.cpp index 6a93fbe..ce87e85 100644 --- a/test/allocate_shared_construct11_test.cpp +++ b/test/allocate_shared_construct11_test.cpp @@ -8,14 +8,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt -#include #include #include #include +#include #include -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - template< class T > class cxx11_allocator { public: @@ -229,12 +227,3 @@ int main() return boost::report_errors(); } - -#else // !defined( BOOST_NO_CXX11_ALLOCATOR ) - -int main() -{ - return 0; -} - -#endif diff --git a/test/shared_ptr_alloc11_test.cpp b/test/shared_ptr_alloc11_test.cpp index dca8c96..9466021 100644 --- a/test/shared_ptr_alloc11_test.cpp +++ b/test/shared_ptr_alloc11_test.cpp @@ -11,13 +11,11 @@ // http://www.boost.org/LICENSE_1_0.txt -#include #include +#include #include #include -#if !defined( BOOST_NO_CXX11_ALLOCATOR ) - template< class T > class cxx11_allocator { public: @@ -105,12 +103,3 @@ int main() return boost::report_errors(); } - -#else // !defined( BOOST_NO_CXX11_ALLOCATOR ) - -int main() -{ - return 0; -} - -#endif diff --git a/test/shared_ptr_alloc_construct11_test.cpp b/test/shared_ptr_alloc_construct11_test.cpp index 3ddabc8..8abd727 100644 --- a/test/shared_ptr_alloc_construct11_test.cpp +++ b/test/shared_ptr_alloc_construct11_test.cpp @@ -5,10 +5,9 @@ Copyright 2017 Glen Joseph Fernandes Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ -#include #include +#include -#if !defined(BOOST_NO_CXX11_ALLOCATOR) struct counters { unsigned allocate; unsigned construct; @@ -120,9 +119,3 @@ int main() } return boost::report_errors(); } -#else -int main() -{ - return 0; -} -#endif