From 6b3fb219cc25c9dffa2e94ab4175c1a9997d8739 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 6 Dec 2021 15:58:48 -0500 Subject: [PATCH] Minor refactoring in allocator access --- include/boost/core/allocator_access.hpp | 81 +++++++++++++------------ 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/include/boost/core/allocator_access.hpp b/include/boost/core/allocator_access.hpp index edf749d..5caba94 100644 --- a/include/boost/core/allocator_access.hpp +++ b/include/boost/core/allocator_access.hpp @@ -47,7 +47,7 @@ namespace detail { template struct alloc_ptr { - typedef typename A::value_type* type; + typedef typename allocator_value_type::type* type; }; template @@ -98,10 +98,46 @@ struct allocator_const_pointer { }; #endif +#if defined(BOOST_NO_CXX11_ALLOCATOR) +template +struct allocator_rebind { + typedef typename A::template rebind::other type; +}; +#else +namespace detail { + +template +struct alloc_to { }; + +template class A, class T, class U, class... V> +struct alloc_to, T> { + typedef A type; +}; + +template +struct alloc_rebind { + typedef typename alloc_to::type type; +}; + +template +struct alloc_rebind::other>::type> { + typedef typename A::template rebind::other type; +}; + +} /* detail */ + +template +struct allocator_rebind { + typedef typename detail::alloc_rebind::type type; +}; +#endif + #if defined(BOOST_NO_CXX11_ALLOCATOR) template struct allocator_void_pointer { - typedef typename A::template rebind::other::pointer type; + typedef typename allocator_pointer::type>::type type; }; #else namespace detail { @@ -130,7 +166,8 @@ struct allocator_void_pointer { #if defined(BOOST_NO_CXX11_ALLOCATOR) template struct allocator_const_void_pointer { - typedef typename A::template rebind::other::const_pointer type; + typedef typename allocator_const_pointer::type>::type type; }; #else namespace detail { @@ -330,41 +367,6 @@ struct allocator_is_always_equal { }; #endif -#if defined(BOOST_NO_CXX11_ALLOCATOR) -template -struct allocator_rebind { - typedef typename A::template rebind::other type; -}; -#else -namespace detail { - -template -struct alloc_to { }; - -template class A, class T, class U, class... V> -struct alloc_to, T> { - typedef A type; -}; - -template -struct alloc_rebind { - typedef typename alloc_to::type type; -}; - -template -struct alloc_rebind::other>::type> { - typedef typename A::template rebind::other type; -}; - -} /* detail */ - -template -struct allocator_rebind { - typedef typename detail::alloc_rebind::type type; -}; -#endif - template inline typename allocator_pointer::type allocator_allocate(A& a, typename allocator_size_type::type n) @@ -587,7 +589,8 @@ inline typename std::enable_if::value, allocator_max_size(const A&) BOOST_NOEXCEPT { return (std::numeric_limits::type>::max)() / sizeof(typename A::value_type); + allocator_size_type::type>::max)() / + sizeof(typename allocator_value_type::type); } #endif