29#ifndef _EXT_ALLOC_TRAITS_H
30#define _EXT_ALLOC_TRAITS_H 1
32#pragma GCC system_header
36namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
38_GLIBCXX_BEGIN_NAMESPACE_VERSION
44template<
typename _Alloc,
typename =
typename _Alloc::value_type>
46#if __cplusplus >= 201103L
50 typedef _Alloc allocator_type;
51#if __cplusplus >= 201103L
59 typedef value_type& reference;
60 typedef const value_type& const_reference;
61 using _Base_type::allocate;
62 using _Base_type::deallocate;
63 using _Base_type::construct;
64 using _Base_type::destroy;
65 using _Base_type::max_size;
68 template<
typename _Ptr>
69 using __is_custom_pointer
70 = std::__and_<std::is_same<pointer, _Ptr>,
71 std::__not_<std::is_pointer<_Ptr>>>;
75 template<
typename _Ptr,
typename... _Args>
76 [[__gnu__::__always_inline__]]
77 static _GLIBCXX14_CONSTEXPR
78 std::__enable_if_t<__is_custom_pointer<_Ptr>::value>
79 construct(_Alloc& __a, _Ptr __p, _Args&&... __args)
80 noexcept(
noexcept(_Base_type::construct(__a, std::__to_address(__p),
81 std::forward<_Args>(__args)...)))
83 _Base_type::construct(__a, std::__to_address(__p),
84 std::forward<_Args>(__args)...);
88 template<
typename _Ptr>
89 [[__gnu__::__always_inline__]]
90 static _GLIBCXX14_CONSTEXPR
91 std::__enable_if_t<__is_custom_pointer<_Ptr>::value>
92 destroy(_Alloc& __a, _Ptr __p)
93 noexcept(
noexcept(_Base_type::destroy(__a, std::__to_address(__p))))
94 { _Base_type::destroy(__a, std::__to_address(__p)); }
96 [[__gnu__::__always_inline__]]
97 static constexpr _Alloc _S_select_on_copy(
const _Alloc& __a)
98 {
return _Base_type::select_on_container_copy_construction(__a); }
100 [[__gnu__::__always_inline__]]
101 static _GLIBCXX14_CONSTEXPR
void _S_on_swap(_Alloc& __a, _Alloc& __b)
102 { std::__alloc_on_swap(__a, __b); }
104 [[__gnu__::__always_inline__]]
105 static constexpr bool _S_propagate_on_copy_assign()
106 {
return _Base_type::propagate_on_container_copy_assignment::value; }
108 [[__gnu__::__always_inline__]]
109 static constexpr bool _S_propagate_on_move_assign()
110 {
return _Base_type::propagate_on_container_move_assignment::value; }
112 [[__gnu__::__always_inline__]]
113 static constexpr bool _S_propagate_on_swap()
114 {
return _Base_type::propagate_on_container_swap::value; }
116 [[__gnu__::__always_inline__]]
117 static constexpr bool _S_always_equal()
118 {
return _Base_type::is_always_equal::value; }
120 __attribute__((__always_inline__))
121 static constexpr bool _S_nothrow_move()
122 {
return _S_propagate_on_move_assign() || _S_always_equal(); }
124 template<
typename _Tp>
126 {
typedef typename _Base_type::template rebind_alloc<_Tp> other; };
129 typedef typename _Alloc::pointer pointer;
130 typedef typename _Alloc::const_pointer const_pointer;
131 typedef typename _Alloc::value_type value_type;
132 typedef typename _Alloc::reference reference;
133 typedef typename _Alloc::const_reference const_reference;
134 typedef typename _Alloc::size_type size_type;
135 typedef typename _Alloc::difference_type difference_type;
137 __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
139 allocate(_Alloc& __a, size_type __n)
140 {
return __a.allocate(__n); }
142 template<
typename _H
int>
143 __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
145 allocate(_Alloc& __a, size_type __n, _Hint __hint)
146 {
return __a.allocate(__n, __hint); }
148 __attribute__((__always_inline__))
149 static void deallocate(_Alloc& __a, pointer __p, size_type __n)
150 { __a.deallocate(__p, __n); }
152 template<
typename _Tp>
153 __attribute__((__always_inline__))
154 static void construct(_Alloc& __a, pointer __p,
const _Tp& __arg)
155 { __a.construct(__p, __arg); }
157 __attribute__((__always_inline__))
158 static void destroy(_Alloc& __a, pointer __p)
159 { __a.destroy(__p); }
161 __attribute__((__always_inline__))
162 static size_type max_size(
const _Alloc& __a)
163 {
return __a.max_size(); }
165 __attribute__((__always_inline__))
166 static const _Alloc& _S_select_on_copy(
const _Alloc& __a) {
return __a; }
168 __attribute__((__always_inline__))
169 static void _S_on_swap(_Alloc& __a, _Alloc& __b)
173 std::__alloc_swap<_Alloc>::_S_do_it(__a, __b);
176 template<
typename _Tp>
178 {
typedef typename _Alloc::template rebind<_Tp>::other other; };
182_GLIBCXX_END_NAMESPACE_VERSION
GNU extensions for public use.
Uniform interface to all allocator types.
__detected_or_t< value_type *, __pointer, _Alloc > pointer
The allocator's pointer type.
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
typename _Diff< _Alloc, pointer >::type difference_type
The allocator's difference type.
typename _Ptr< __c_pointer, const value_type >::type const_pointer
The allocator's const pointer type.
_Alloc::value_type value_type
The allocated type.
Uniform interface to C++98 and C++11 allocators.