]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/circular_buffer/allocators.hpp
buildsys: switch source download to quincy
[ceph.git] / ceph / src / boost / boost / circular_buffer / allocators.hpp
CommitLineData
92f5a8d4
TL
1// Copyright 2018 Glen Joseph Fernandes
2// (glenjofe@gmail.com)
3//
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)
7
8#ifndef BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
9#define BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
10
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
16#endif
17#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
18#include <memory>
19#else
20#include <new>
21#endif
22#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
23#include <utility>
24#endif
25
26namespace boost {
27namespace cb_details {
28
29#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
30using std::allocator_traits;
31#else
32template<class A>
33struct 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;
39
40 static size_type max_size(const A& a) BOOST_NOEXCEPT {
41 return a.max_size();
42 }
43
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)...);
49 }
50#else
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));
54 }
55#endif
56#else
57 template<class U, class V>
58 static void construct(const A&, U* ptr, const V& value) {
59 ::new((void*)ptr) U(value);
60 }
61
62 template<class U, class V>
63 static void construct(const A&, U* ptr, V& value) {
64 ::new((void*)ptr) U(value);
65 }
66#endif
67
68 template<class U>
69 static void destroy(const A&, U* ptr) {
70 (void)ptr;
71 ptr->~U();
72 }
73};
74#endif
75
76} // cb_details
77} // boost
78
79#endif