// Copyright 2018 Glen Joseph Fernandes // (glenjofe@gmail.com) // // 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) #ifndef BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP #define BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP #include #if defined(BOOST_NO_CXX11_ALLOCATOR) #define BOOST_CB_NO_CXX11_ALLOCATOR #elif defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40800) #define BOOST_CB_NO_CXX11_ALLOCATOR #endif #if !defined(BOOST_CB_NO_CXX11_ALLOCATOR) #include #else #include #endif #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include #endif namespace boost { namespace cb_details { #if !defined(BOOST_CB_NO_CXX11_ALLOCATOR) using std::allocator_traits; #else template struct allocator_traits { typedef typename A::value_type value_type; typedef typename A::pointer pointer; typedef typename A::const_pointer const_pointer; typedef typename A::difference_type difference_type; typedef typename A::size_type size_type; static size_type max_size(const A& a) BOOST_NOEXCEPT { return a.max_size(); } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template static void construct(const A&, U* ptr, Args&&... args) { ::new((void*)ptr) U(std::forward(args)...); } #else template static void construct(const A&, U* ptr, V&& value) { ::new((void*)ptr) U(std::forward(value)); } #endif #else template static void construct(const A&, U* ptr, const V& value) { ::new((void*)ptr) U(value); } template static void construct(const A&, U* ptr, V& value) { ::new((void*)ptr) U(value); } #endif template static void destroy(const A&, U* ptr) { (void)ptr; ptr->~U(); } }; #endif } // cb_details } // boost #endif