2 Copyright 2021 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_CORE_ALLOCATOR_TRAITS_HPP
9 #define BOOST_CORE_ALLOCATOR_TRAITS_HPP
11 #include <boost/core/allocator_access.hpp>
16 struct allocator_traits {
17 typedef A allocator_type;
19 typedef typename allocator_value_type<A>::type value_type;
21 typedef typename allocator_pointer<A>::type pointer;
23 typedef typename allocator_const_pointer<A>::type const_pointer;
25 typedef typename allocator_void_pointer<A>::type void_pointer;
27 typedef typename allocator_const_void_pointer<A>::type const_void_pointer;
29 typedef typename allocator_difference_type<A>::type difference_type;
31 typedef typename allocator_size_type<A>::type size_type;
33 typedef typename allocator_propagate_on_container_copy_assignment<A>::type
34 propagate_on_container_copy_assignment;
36 typedef typename allocator_propagate_on_container_move_assignment<A>::type
37 propagate_on_container_move_assignment;
39 typedef typename allocator_propagate_on_container_swap<A>::type
40 propagate_on_container_swap;
42 typedef typename allocator_is_always_equal<A>::type is_always_equal;
44 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
46 using rebind_traits = allocator_traits<typename
47 allocator_rebind<A, T>::type>;
51 : allocator_traits<typename allocator_rebind<A, T>::type> { };
54 static pointer allocate(A& a, size_type n) {
55 return boost::allocator_allocate(a, n);
58 static pointer allocate(A& a, size_type n, const_void_pointer h) {
59 return boost::allocator_allocate(a, n, h);
62 static void deallocate(A& a, pointer p, size_type n) {
63 return boost::allocator_deallocate(a, p, n);
67 static void construct(A& a, T* p) {
68 boost::allocator_construct(a, p);
71 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
72 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
73 template<class T, class V, class... Args>
74 static void construct(A& a, T* p, V&& v, Args&&... args) {
75 boost::allocator_construct(a, p, std::forward<V>(v),
76 std::forward<Args>(args)...);
79 template<class T, class V>
80 static void construct(A& a, T* p, V&& v) {
81 boost::allocator_construct(a, p, std::forward<V>(v));
85 template<class T, class V>
86 static void construct(A& a, T* p, const V& v) {
87 boost::allocator_construct(a, p, v);
90 template<class T, class V>
91 static void construct(A& a, T* p, V& v) {
92 boost::allocator_construct(a, p, v);
97 static void destroy(A& a, T* p) {
98 boost::allocator_destroy(a, p);
101 static size_type max_size(const A& a) BOOST_NOEXCEPT {
102 return boost::allocator_max_size(a);
105 static A select_on_container_copy_construction(const A& a) {
106 return boost::allocator_select_on_container_copy_construction(a);