29 #ifndef _ARRAY_ALLOCATOR_H
30 #define _ARRAY_ALLOCATOR_H 1
32 #include <bits/c++config.h>
37 #if __cplusplus >= 201103L
38 #include <type_traits>
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Tp>
50 class array_allocator_base
53 typedef size_t size_type;
56 typedef const _Tp* const_pointer;
57 typedef _Tp& reference;
58 typedef const _Tp& const_reference;
59 typedef _Tp value_type;
62 address(reference __x)
const _GLIBCXX_NOEXCEPT
63 {
return std::__addressof(__x); }
66 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
67 {
return std::__addressof(__x); }
70 deallocate(pointer, size_type)
76 max_size() const _GLIBCXX_USE_NOEXCEPT
77 {
return size_t(-1) /
sizeof(_Tp); }
79 #if __cplusplus >= 201103L
80 template<
typename _Up,
typename... _Args>
82 construct(_Up* __p, _Args&&... __args)
83 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
85 template<typename _Up>
87 destroy(_Up* __p) { __p->~_Up(); }
92 construct(pointer __p,
const _Tp& __val)
93 { ::new((
void *)__p) value_type(__val); }
96 destroy(pointer __p) { __p->~_Tp(); }
105 template<
typename _Tp,
typename _Array = std::tr1::array<_Tp, 1> >
106 class array_allocator :
public array_allocator_base<_Tp>
109 typedef size_t size_type;
111 typedef _Tp* pointer;
112 typedef const _Tp* const_pointer;
113 typedef _Tp& reference;
114 typedef const _Tp& const_reference;
115 typedef _Tp value_type;
116 typedef _Array array_type;
118 #if __cplusplus >= 201103L
125 array_type* _M_array;
129 template<
typename _Tp1,
typename _Array1 = _Array>
131 {
typedef array_allocator<_Tp1, _Array1> other; };
133 array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT
134 : _M_array(__array), _M_used(size_type()) { }
136 array_allocator(
const array_allocator& __o) _GLIBCXX_USE_NOEXCEPT
137 : _M_array(__o._M_array), _M_used(__o._M_used) { }
139 template<
typename _Tp1,
typename _Array1>
140 array_allocator(
const array_allocator<_Tp1, _Array1>&)
141 _GLIBCXX_USE_NOEXCEPT
142 : _M_array(0), _M_used(size_type()) { }
144 ~array_allocator() _GLIBCXX_USE_NOEXCEPT { }
147 allocate(size_type __n,
const void* = 0)
149 if (_M_array == 0 || _M_used + __n > _M_array->size())
150 std::__throw_bad_alloc();
151 pointer __ret = _M_array->begin() + _M_used;
157 template<
typename _Tp,
typename _Array>
159 operator==(
const array_allocator<_Tp, _Array>&,
160 const array_allocator<_Tp, _Array>&)
163 template<
typename _Tp,
typename _Array>
165 operator!=(
const array_allocator<_Tp, _Array>&,
166 const array_allocator<_Tp, _Array>&)
169 _GLIBCXX_END_NAMESPACE_VERSION
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
namespace std _GLIBCXX_VISIBILITY(default)
Definition: auto_ptr.h:36
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
__SIZE_TYPE__ size_t
Definition: stddef.h:212
std::tr1::integral_constant< int, 1 > true_type
Definition: type_utils.hpp:70
__PTRDIFF_TYPE__ ptrdiff_t
Definition: stddef.h:147