30 #ifndef _ARRAY_ALLOCATOR_H
31 #define _ARRAY_ALLOCATOR_H 1
39 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
45 template<typename _Tp>
49 typedef size_t size_type;
50 typedef ptrdiff_t difference_type;
52 typedef const _Tp* const_pointer;
53 typedef _Tp& reference;
54 typedef const _Tp& const_reference;
55 typedef _Tp value_type;
58 address(reference __x)
const {
return &__x; }
61 address(const_reference __x)
const {
return &__x; }
64 deallocate(pointer, size_type)
70 max_size()
const throw()
71 {
return size_t(-1) /
sizeof(_Tp); }
76 construct(pointer __p,
const _Tp& __val)
77 { ::new((
void *)__p) value_type(__val); }
79 #ifdef __GXX_EXPERIMENTAL_CXX0X__
80 template<
typename... _Args>
82 construct(pointer __p, _Args&&... __args)
83 { ::new((
void *)__p) _Tp(std::forward<_Args>(__args)...); }
87 destroy(pointer __p) { __p->~_Tp(); }
95 template<
typename _Tp,
typename _Array = std::tr1::array<_Tp, 1> >
99 typedef size_t size_type;
100 typedef ptrdiff_t difference_type;
101 typedef _Tp* pointer;
102 typedef const _Tp* const_pointer;
103 typedef _Tp& reference;
104 typedef const _Tp& const_reference;
105 typedef _Tp value_type;
106 typedef _Array array_type;
109 array_type* _M_array;
113 template<
typename _Tp1,
typename _Array1 = _Array>
118 : _M_array(__array), _M_used(size_type()) { }
121 : _M_array(__o._M_array), _M_used(__o._M_used) { }
123 template<
typename _Tp1,
typename _Array1>
125 : _M_array(NULL), _M_used(size_type()) { }
130 allocate(size_type __n,
const void* = 0)
132 if (_M_array == 0 || _M_used + __n > _M_array->size())
133 std::__throw_bad_alloc();
134 pointer __ret = _M_array->begin() + _M_used;
140 template<
typename _Tp,
typename _Array>
146 template<
typename _Tp,
typename _Array>
148 operator!=(
const array_allocator<_Tp, _Array>&,
149 const array_allocator<_Tp, _Array>&)
152 _GLIBCXX_END_NAMESPACE
An allocator that uses previously allocated memory. This memory can be externally, globally, or otherwise allocated.