29 #ifndef _EXT_ALLOC_TRAITS_H
30 #define _EXT_ALLOC_TRAITS_H 1
32 #pragma GCC system_header
34 #ifdef __GXX_EXPERIMENTAL_CXX0X__
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
44 template<
typename>
struct allocator;
45 _GLIBCXX_END_NAMESPACE_VERSION
48 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
50 _GLIBCXX_BEGIN_NAMESPACE_VERSION
52 #ifdef __GXX_EXPERIMENTAL_CXX0X__
53 template<
typename _Alloc>
54 struct __allocator_always_compares_equal
55 {
static const bool value =
false; };
57 template<
typename _Alloc>
58 const bool __allocator_always_compares_equal<_Alloc>::value;
60 template<
typename _Tp>
61 struct __allocator_always_compares_equal<std::allocator<_Tp>>
62 {
static const bool value =
true; };
64 template<
typename _Tp>
65 const bool __allocator_always_compares_equal<std::allocator<_Tp>>::value;
69 template<
typename _Tp,
typename _Array>
71 {
static const bool value =
true; };
73 template<
typename _Tp,
typename _Array>
75 __allocator_always_compares_equal<array_allocator<_Tp, _Array>>::value;
77 template<
typename>
struct mt_allocator;
79 template<
typename _Tp>
80 struct __allocator_always_compares_equal<mt_allocator<_Tp>>
81 {
static const bool value =
true; };
83 template<
typename _Tp>
84 const bool __allocator_always_compares_equal<mt_allocator<_Tp>>::value;
88 template<
typename _Tp>
90 {
static const bool value =
true; };
92 template<
typename _Tp>
93 const bool __allocator_always_compares_equal<new_allocator<_Tp>>::value;
95 template<
typename>
struct pool_allocator;
97 template<
typename _Tp>
98 struct __allocator_always_compares_equal<pool_allocator<_Tp>>
99 {
static const bool value =
true; };
101 template<
typename _Tp>
102 const bool __allocator_always_compares_equal<pool_allocator<_Tp>>::value;
109 template<
typename _Alloc>
111 #ifdef __GXX_EXPERIMENTAL_CXX0X__
116 #ifdef __GXX_EXPERIMENTAL_CXX0X__
132 template<
typename _Ptr>
133 struct __is_custom_pointer
135 && !std::is_pointer<_Ptr>::value>
140 template<
typename _Ptr,
typename... _Args>
142 construct(_Alloc& __a, _Ptr __p, _Args&&... __args)
145 std::forward<_Args>(__args)...);
149 template<
typename _Ptr>
151 destroy(_Alloc& __a, _Ptr __p)
154 static _Alloc _S_select_on_copy(
const _Alloc& __a)
157 static void _S_on_swap(_Alloc& __a, _Alloc& __b)
158 { std::__alloc_on_swap(__a, __b); }
160 static constexpr
bool _S_propagate_on_copy_assign()
161 {
return _Base_type::propagate_on_container_copy_assignment::value; }
163 static constexpr
bool _S_propagate_on_move_assign()
164 {
return _Base_type::propagate_on_container_move_assignment::value; }
166 static constexpr
bool _S_propagate_on_swap()
167 {
return _Base_type::propagate_on_container_swap::value; }
169 static constexpr
bool _S_always_equal()
170 {
return __allocator_always_compares_equal<_Alloc>::value; }
172 static constexpr
bool _S_nothrow_move()
173 {
return _S_propagate_on_move_assign() || _S_always_equal(); }
175 static constexpr
bool _S_nothrow_swap()
178 return !_S_propagate_on_swap()
179 || noexcept(swap(std::declval<_Alloc&>(), std::declval<_Alloc&>()));
182 template<
typename _Tp>
184 {
typedef typename _Base_type::template rebind_alloc<_Tp> other; };
187 typedef typename _Alloc::pointer
pointer;
189 typedef typename _Alloc::value_type
value_type;
190 typedef typename _Alloc::reference reference;
191 typedef typename _Alloc::const_reference const_reference;
192 typedef typename _Alloc::size_type
size_type;
196 {
return __a.allocate(__n); }
199 { __a.deallocate(__p, __n); }
201 template<
typename _Tp>
202 static void construct(_Alloc& __a,
pointer __p,
const _Tp& __arg)
203 { __a.construct(__p, __arg); }
205 static void destroy(_Alloc& __a,
pointer __p)
206 { __a.destroy(__p); }
209 {
return __a.max_size(); }
211 static const _Alloc& _S_select_on_copy(
const _Alloc& __a) {
return __a; }
213 static void _S_on_swap(_Alloc& __a, _Alloc& __b)
217 std::__alloc_swap<_Alloc>::_S_do_it(__a, __b);
220 template<
typename _Tp>
222 {
typedef typename _Alloc::template rebind<_Tp>::other other; };
226 _GLIBCXX_END_NAMESPACE_VERSION
static void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
__size_type size_type
The allocator's size type.
Uniform interface to C++98 and C++0x allocators.
static pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
Define a member typedef type only if a boolean constant is true.
_Alloc allocator_type
The allocator type.
An allocator that uses previously allocated memory. This memory can be externally, globally, or otherwise allocated.
static size_type max_size(const _Alloc &__a)
The maximum supported allocation size.
static auto construct(_Alloc &__a, _Tp *__p, _Args &&...__args) -> decltype(_S_construct(__a, __p, std::forward< _Args >(__args)...))
Construct an object of type _Tp.
__const_pointer const_pointer
The allocator's const pointer type.
An allocator that uses global new, as per [20.4].This is precisely the allocator defined in the C++ S...
Uniform interface to all allocator types.
static _Alloc select_on_container_copy_construction(const _Alloc &__rhs)
Obtain an allocator to use when copying a container.
_Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
__pointer pointer
The allocator's pointer type.
static void destroy(_Alloc &__a, _Tp *__p)
Destroy an object of type _Tp.
_Alloc::value_type value_type
The allocated type.