29 #ifndef _NEW_ALLOCATOR_H
30 #define _NEW_ALLOCATOR_H 1
36 #if __cplusplus >= 201103L
40 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
57 template<
typename _Tp>
61 typedef size_t size_type;
62 typedef ptrdiff_t difference_type;
64 typedef const _Tp* const_pointer;
65 typedef _Tp& reference;
66 typedef const _Tp& const_reference;
67 typedef _Tp value_type;
69 template<
typename _Tp1>
71 {
typedef new_allocator<_Tp1> other; };
73 #if __cplusplus >= 201103L
79 new_allocator() _GLIBCXX_USE_NOEXCEPT { }
81 new_allocator(
const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
83 template<
typename _Tp1>
84 new_allocator(
const new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
86 ~new_allocator() _GLIBCXX_USE_NOEXCEPT { }
89 address(reference __x)
const _GLIBCXX_NOEXCEPT
93 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
99 allocate(size_type __n,
const void* = 0)
101 if (__n > this->max_size())
102 std::__throw_bad_alloc();
104 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
109 deallocate(pointer __p, size_type)
110 { ::operator
delete(__p); }
113 max_size() const _GLIBCXX_USE_NOEXCEPT
114 {
return size_t(-1) /
sizeof(_Tp); }
116 #if __cplusplus >= 201103L
117 template<
typename _Up,
typename... _Args>
119 construct(_Up* __p, _Args&&... __args)
120 { ::new((
void *)__p) _Up(std::
forward<_Args>(__args)...); }
122 template<typename _Up>
124 destroy(_Up* __p) { __p->~_Up(); }
129 construct(pointer __p,
const _Tp& __val)
130 { ::new((
void *)__p) _Tp(__val); }
133 destroy(pointer __p) { __p->~_Tp(); }
137 template<
typename _Tp>
139 operator==(
const new_allocator<_Tp>&,
const new_allocator<_Tp>&)
142 template<
typename _Tp>
144 operator!=(
const new_allocator<_Tp>&,
const new_allocator<_Tp>&)
147 _GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.