2 * Copyright Andrey Semashev 2018.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
8 * \file allocator_traits.hpp
9 * \author Andrey Semashev
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
16 #ifndef BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
17 #define BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
20 #include <boost/log/detail/config.hpp>
21 #if defined(BOOST_NO_CXX11_ALLOCATOR)
22 #include <boost/container/allocator_traits.hpp>
24 #include <boost/log/detail/header.hpp>
26 #ifdef BOOST_HAS_PRAGMA_ONCE
32 BOOST_LOG_OPEN_NAMESPACE
36 // A portable name for allocator traits
37 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
38 using std::allocator_traits;
40 using boost::container::allocator_traits;
44 * \brief A standalone trait to rebind an allocator to another type.
46 * The important difference from <tt>std::allocator_traits<Alloc>::rebind_alloc<U></tt> is that this
47 * trait does not require template aliases and thus is compatible with C++03. There is
48 * <tt>boost::container::allocator_traits<Alloc>::portable_rebind_alloc<U></tt>, but it is not present in <tt>std::allocator_traits</tt>.
49 * It will also attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template. We don't want
50 * that to happen because it prohibits using <tt>std::allocator<void></tt> in C++17 and later, which deprecated
51 * this allocator specialization. This standalone trait does not use the nested <tt>rebind</tt> template in this case.
53 template< typename Allocator, typename U >
56 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
57 typedef typename std::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE rebind_alloc< U > type;
59 typedef typename boost::container::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE portable_rebind_alloc< U >::type type;
63 template< typename U >
64 struct rebind_alloc< std::allocator< void >, U >
66 typedef std::allocator< U > type;
71 BOOST_LOG_CLOSE_NAMESPACE // namespace log
75 #include <boost/log/detail/footer.hpp>
77 #endif // BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_