Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:20

0001 /*
0002  *             Copyright Andrey Semashev 2018.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   allocator_traits.hpp
0009  * \author Andrey Semashev
0010  * \date   03.01.2018
0011  *
0012  * \brief  This header is the Boost.Log library implementation, see the library documentation
0013  *         at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
0014  */
0015 
0016 #ifndef BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
0017 #define BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
0018 
0019 #include <memory>
0020 #include <boost/log/detail/config.hpp>
0021 #if defined(BOOST_NO_CXX11_ALLOCATOR)
0022 #include <boost/core/allocator_access.hpp>
0023 #include <boost/core/allocator_traits.hpp>
0024 #endif
0025 #include <boost/log/utility/use_std_allocator.hpp>
0026 #include <boost/log/detail/header.hpp>
0027 
0028 #ifdef BOOST_HAS_PRAGMA_ONCE
0029 #pragma once
0030 #endif
0031 
0032 namespace boost {
0033 
0034 BOOST_LOG_OPEN_NAMESPACE
0035 
0036 namespace aux {
0037 
0038 // A portable name for allocator traits
0039 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
0040 using std::allocator_traits;
0041 #else
0042 using boost::allocator_traits;
0043 #endif
0044 
0045 /*!
0046  * \brief A standalone trait to rebind an allocator to another type.
0047  *
0048  * This trait mostly exists to hide differences between <tt>std::allocator_traits</tt> and <tt>boost::allocator_traits</tt>
0049  * in terms of allocator rebinding and also provide custom behavior in some cases.
0050  */
0051 template< typename Allocator, typename U >
0052 struct rebind_alloc
0053 {
0054 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
0055     typedef typename std::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE rebind_alloc< U > type;
0056 #else
0057     typedef typename boost::allocator_rebind< Allocator, U >::type type;
0058 #endif
0059 };
0060 
0061 /*!
0062  * This specialization mostly exists to keep <tt>std::allocator&lt;void&gt;</tt> working.
0063  * The default template will attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template.
0064  * We don't want that to happen because it prohibits using <tt>std::allocator&lt;void&gt;</tt> in C++17 and later, which deprecated
0065  * this allocator specialization. This specialization does not use the nested <tt>rebind</tt> template in this case.
0066  */
0067 template< typename T, typename U >
0068 struct rebind_alloc< std::allocator< T >, U >
0069 {
0070     typedef std::allocator< U > type;
0071 };
0072 
0073 template< typename U >
0074 struct rebind_alloc< use_std_allocator, U >
0075 {
0076     typedef std::allocator< U > type;
0077 };
0078 
0079 } // namespace aux
0080 
0081 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0082 
0083 } // namespace boost
0084 
0085 #include <boost/log/detail/footer.hpp>
0086 
0087 #endif // BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_