30 #ifndef _NEW_ALLOCATOR_H
31 #define _NEW_ALLOCATOR_H 1
37 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
50 template<typename _Tp>
54 typedef size_t size_type;
55 typedef ptrdiff_t difference_type;
57 typedef const _Tp* const_pointer;
58 typedef _Tp& reference;
59 typedef const _Tp& const_reference;
60 typedef _Tp value_type;
62 template<
typename _Tp1>
66 new_allocator()
throw() { }
68 new_allocator(
const new_allocator&)
throw() { }
70 template<
typename _Tp1>
73 ~new_allocator()
throw() { }
76 address(reference __x)
const {
return &__x; }
79 address(const_reference __x)
const {
return &__x; }
84 allocate(size_type __n,
const void* = 0)
86 if (__builtin_expect(__n > this->max_size(),
false))
87 std::__throw_bad_alloc();
89 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
94 deallocate(pointer __p, size_type)
95 { ::operator
delete(__p); }
98 max_size()
const throw()
99 {
return size_t(-1) /
sizeof(_Tp); }
104 construct(pointer __p,
const _Tp& __val)
105 { ::new((
void *)__p) _Tp(__val); }
107 #ifdef __GXX_EXPERIMENTAL_CXX0X__
108 template<
typename... _Args>
110 construct(pointer __p, _Args&&... __args)
111 { ::new((
void *)__p) _Tp(std::forward<_Args>(__args)...); }
115 destroy(pointer __p) { __p->~_Tp(); }
118 template<
typename _Tp>
123 template<
typename _Tp>
125 operator!=(
const new_allocator<_Tp>&,
const new_allocator<_Tp>&)
128 _GLIBCXX_END_NAMESPACE
An allocator that uses global new, as per [20.4].This is precisely the allocator defined in the C++ S...