29 #ifndef _ARRAY_ALLOCATOR_H
30 #define _ARRAY_ALLOCATOR_H 1
37 #if __cplusplus >= 201103L
38 #include <type_traits>
42 #pragma GCC diagnostic push
43 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
45 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53 template<
typename _Tp>
57 typedef size_t size_type;
58 typedef ptrdiff_t difference_type;
60 typedef const _Tp* const_pointer;
61 typedef _Tp& reference;
62 typedef const _Tp& const_reference;
63 typedef _Tp value_type;
66 address(reference __x)
const _GLIBCXX_NOEXCEPT
70 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
74 deallocate(pointer, size_type)
80 max_size()
const _GLIBCXX_USE_NOEXCEPT
81 {
return size_t(-1) /
sizeof(_Tp); }
83 #if __cplusplus >= 201103L
84 template<
typename _Up,
typename... _Args>
86 construct(_Up* __p, _Args&&... __args)
87 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
89 template<
typename _Up>
91 destroy(_Up* __p) { __p->~_Up(); }
96 construct(pointer __p,
const _Tp& __val)
97 { ::new((
void *)__p) value_type(__val); }
100 destroy(pointer __p) { __p->~_Tp(); }
102 } _GLIBCXX_DEPRECATED;
109 template<
typename _Tp,
typename _Array = std::tr1::array<_Tp, 1> >
113 typedef size_t size_type;
114 typedef ptrdiff_t difference_type;
115 typedef _Tp* pointer;
116 typedef const _Tp* const_pointer;
117 typedef _Tp& reference;
118 typedef const _Tp& const_reference;
119 typedef _Tp value_type;
120 typedef _Array array_type;
122 #if __cplusplus >= 201103L
125 typedef std::true_type propagate_on_container_move_assignment;
129 array_type* _M_array;
133 template<
typename _Tp1,
typename _Array1 = _Array>
137 } _GLIBCXX_DEPRECATED;
139 array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT
140 : _M_array(__array), _M_used(size_type()) { }
142 array_allocator(
const array_allocator& __o) _GLIBCXX_USE_NOEXCEPT
143 : _M_array(__o._M_array), _M_used(__o._M_used) { }
145 template<
typename _Tp1,
typename _Array1>
146 array_allocator(
const array_allocator<_Tp1, _Array1>&)
147 _GLIBCXX_USE_NOEXCEPT
148 : _M_array(0), _M_used(size_type()) { }
150 ~array_allocator() _GLIBCXX_USE_NOEXCEPT { }
153 allocate(size_type __n,
const void* = 0)
155 if (_M_array == 0 || _M_used + __n > _M_array->size())
156 std::__throw_bad_alloc();
157 pointer __ret = _M_array->begin() + _M_used;
161 } _GLIBCXX_DEPRECATED;
163 template<
typename _Tp,
typename _Array>
165 operator==(
const array_allocator<_Tp, _Array>&,
166 const array_allocator<_Tp, _Array>&)
169 template<
typename _Tp,
typename _Array>
171 operator!=(
const array_allocator<_Tp, _Array>&,
172 const array_allocator<_Tp, _Array>&)
175 _GLIBCXX_END_NAMESPACE_VERSION
178 #pragma GCC diagnostic pop
GNU extensions for public use.
An allocator that uses previously allocated memory. This memory can be externally, globally, or otherwise allocated.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.