29 #ifndef _EXT_ALLOC_TRAITS_H 30 #define _EXT_ALLOC_TRAITS_H 1 32 #pragma GCC system_header 34 #if __cplusplus >= 201103L 41 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Alloc,
typename =
typename _Alloc::value_type>
51 #if __cplusplus >= 201103L
56 #if __cplusplus >= 201103L 66 using _Base_type::allocate;
67 using _Base_type::deallocate;
68 using _Base_type::construct;
69 using _Base_type::destroy;
70 using _Base_type::max_size;
73 template<
typename _Ptr>
74 using __is_custom_pointer
75 = std::__and_<std::is_same<pointer, _Ptr>,
76 std::__not_<std::is_pointer<_Ptr>>>;
80 template<
typename _Ptr,
typename... _Args>
82 construct(_Alloc& __a, _Ptr __p, _Args&&... __args)
83 noexcept(noexcept(_Base_type::construct(__a, std::__to_address(__p),
84 std::forward<_Args>(__args)...)))
86 _Base_type::construct(__a, std::__to_address(__p),
87 std::forward<_Args>(__args)...);
91 template<
typename _Ptr>
93 destroy(_Alloc& __a, _Ptr __p)
94 noexcept(noexcept(_Base_type::destroy(__a, std::__to_address(__p))))
95 { _Base_type::destroy(__a, std::__to_address(__p)); }
97 static _Alloc _S_select_on_copy(
const _Alloc& __a)
98 {
return _Base_type::select_on_container_copy_construction(__a); }
100 static void _S_on_swap(_Alloc& __a, _Alloc& __b)
101 { std::__alloc_on_swap(__a, __b); }
103 static constexpr
bool _S_propagate_on_copy_assign()
104 {
return _Base_type::propagate_on_container_copy_assignment::value; }
106 static constexpr
bool _S_propagate_on_move_assign()
107 {
return _Base_type::propagate_on_container_move_assignment::value; }
109 static constexpr
bool _S_propagate_on_swap()
110 {
return _Base_type::propagate_on_container_swap::value; }
112 static constexpr
bool _S_always_equal()
113 {
return _Base_type::is_always_equal::value; }
115 static constexpr
bool _S_nothrow_move()
116 {
return _S_propagate_on_move_assign() || _S_always_equal(); }
118 template<
typename _Tp>
120 {
typedef typename _Base_type::template rebind_alloc<_Tp> other; };
123 typedef typename _Alloc::pointer
pointer;
125 typedef typename _Alloc::value_type
value_type;
126 typedef typename _Alloc::reference reference;
127 typedef typename _Alloc::const_reference const_reference;
128 typedef typename _Alloc::size_type
size_type;
131 _GLIBCXX_NODISCARD
static pointer 133 {
return __a.allocate(__n); }
136 { __a.deallocate(__p, __n); }
138 template<
typename _Tp>
139 static void construct(_Alloc& __a,
pointer __p,
const _Tp& __arg)
140 { __a.construct(__p, __arg); }
142 static void destroy(_Alloc& __a,
pointer __p)
143 { __a.destroy(__p); }
145 static size_type max_size(
const _Alloc& __a)
146 {
return __a.max_size(); }
148 static const _Alloc& _S_select_on_copy(
const _Alloc& __a) {
return __a; }
150 static void _S_on_swap(_Alloc& __a, _Alloc& __b)
154 std::__alloc_swap<_Alloc>::_S_do_it(__a, __b);
157 template<
typename _Tp>
159 {
typedef typename _Alloc::template rebind<_Tp>::other other; };
163 _GLIBCXX_END_NAMESPACE_VERSION
__detected_or_t< value_type *, __pointer, _Alloc > pointer
The allocator's pointer type.
typename _Ptr< __c_pointer, const value_type >::type const_pointer
The allocator's const pointer type.
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
Uniform interface to all allocator types.
_Alloc::value_type value_type
The allocated type.
Uniform interface to C++98 and C++11 allocators.
_Alloc allocator_type
The allocator type.
GNU extensions for public use.
typename _Diff< _Alloc, pointer >::type difference_type
The allocator's difference type.
Define a member typedef type only if a boolean constant is true.