1 // Copyright 2018 Glen Joseph Fernandes
2 // (glenjofe@gmail.com)
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
9 #define BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
11 #include <boost/config.hpp>
12 #if defined(BOOST_NO_CXX11_ALLOCATOR)
13 #define BOOST_CB_NO_CXX11_ALLOCATOR
14 #elif defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40800)
15 #define BOOST_CB_NO_CXX11_ALLOCATOR
17 #if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
22 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
27 namespace cb_details {
29 #if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
30 using std::allocator_traits;
33 struct allocator_traits {
34 typedef typename A::value_type value_type;
35 typedef typename A::pointer pointer;
36 typedef typename A::const_pointer const_pointer;
37 typedef typename A::difference_type difference_type;
38 typedef typename A::size_type size_type;
40 static size_type max_size(const A& a) BOOST_NOEXCEPT {
44 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
45 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
46 template<class U, class... Args>
47 static void construct(const A&, U* ptr, Args&&... args) {
48 ::new((void*)ptr) U(std::forward<Args>(args)...);
51 template<class U, class V>
52 static void construct(const A&, U* ptr, V&& value) {
53 ::new((void*)ptr) U(std::forward<V>(value));
57 template<class U, class V>
58 static void construct(const A&, U* ptr, const V& value) {
59 ::new((void*)ptr) U(value);
62 template<class U, class V>
63 static void construct(const A&, U* ptr, V& value) {
64 ::new((void*)ptr) U(value);
69 static void destroy(const A&, U* ptr) {