30 #ifndef _ARRAY_ALLOCATOR_H
31 #define _ARRAY_ALLOCATOR_H 1
39 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 template<
typename _Tp>
51 typedef size_t size_type;
52 typedef ptrdiff_t difference_type;
54 typedef const _Tp* const_pointer;
55 typedef _Tp& reference;
56 typedef const _Tp& const_reference;
57 typedef _Tp value_type;
60 address(reference __x)
const {
return std::__addressof(__x); }
63 address(const_reference __x)
const {
return std::__addressof(__x); }
66 deallocate(pointer, size_type)
72 max_size()
const throw()
73 {
return size_t(-1) /
sizeof(_Tp); }
78 construct(pointer __p,
const _Tp& __val)
79 { ::new((
void *)__p) value_type(__val); }
81 #ifdef __GXX_EXPERIMENTAL_CXX0X__
82 template<
typename... _Args>
84 construct(pointer __p, _Args&&... __args)
85 { ::new((
void *)__p) _Tp(std::forward<_Args>(__args)...); }
89 destroy(pointer __p) { __p->~_Tp(); }
97 template<
typename _Tp,
typename _Array = std::tr1::array<_Tp, 1> >
101 typedef size_t size_type;
102 typedef ptrdiff_t difference_type;
103 typedef _Tp* pointer;
104 typedef const _Tp* const_pointer;
105 typedef _Tp& reference;
106 typedef const _Tp& const_reference;
107 typedef _Tp value_type;
108 typedef _Array array_type;
111 array_type* _M_array;
115 template<
typename _Tp1,
typename _Array1 = _Array>
120 : _M_array(__array), _M_used(size_type()) { }
123 : _M_array(__o._M_array), _M_used(__o._M_used) { }
125 template<
typename _Tp1,
typename _Array1>
127 : _M_array(0), _M_used(size_type()) { }
132 allocate(size_type __n,
const void* = 0)
134 if (_M_array == 0 || _M_used + __n > _M_array->size())
135 std::__throw_bad_alloc();
136 pointer __ret = _M_array->begin() + _M_used;
142 template<
typename _Tp,
typename _Array>
148 template<
typename _Tp,
typename _Array>
150 operator!=(
const array_allocator<_Tp, _Array>&,
151 const array_allocator<_Tp, _Array>&)
154 _GLIBCXX_END_NAMESPACE_VERSION
An allocator that uses previously allocated memory. This memory can be externally, globally, or otherwise allocated.