29#ifndef _NEW_ALLOCATOR_H
30#define _NEW_ALLOCATOR_H 1
36#if __cplusplus >= 201103L
40namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
42_GLIBCXX_BEGIN_NAMESPACE_VERSION
54 template<
typename _Tp>
58 typedef _Tp value_type;
59 typedef std::size_t size_type;
60 typedef std::ptrdiff_t difference_type;
61#if __cplusplus <= 201703L
63 typedef const _Tp* const_pointer;
64 typedef _Tp& reference;
65 typedef const _Tp& const_reference;
67 template<
typename _Tp1>
72#if __cplusplus >= 201103L
84 template<
typename _Tp1>
88#if __cplusplus <= 201703L
92 address(reference __x)
const _GLIBCXX_NOEXCEPT
96 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
102 _GLIBCXX_NODISCARD _Tp*
103 allocate(size_type __n,
const void* =
static_cast<const void*
>(0))
105#if __cplusplus >= 201103L
108 static_assert(
sizeof(_Tp) != 0,
"cannot allocate incomplete types");
111 if (__builtin_expect(__n > this->_M_max_size(),
false))
115 if (__n > (std::size_t(-1) /
sizeof(_Tp)))
116 std::__throw_bad_array_new_length();
117 std::__throw_bad_alloc();
121 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
123 std::align_val_t __al = std::align_val_t(
alignof(_Tp));
124 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp), __al));
127 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
132 deallocate(_Tp* __p, size_type __t __attribute__ ((__unused__)))
135 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
137 ::operator
delete(__p,
138# if __cpp_sized_deallocation
141 std::align_val_t(
alignof(_Tp)));
145 ::operator
delete(__p
146#if __cpp_sized_deallocation
152#if __cplusplus <= 201703L
154 max_size()
const _GLIBCXX_USE_NOEXCEPT
155 {
return _M_max_size(); }
157#if __cplusplus >= 201103L
158 template<
typename _Up,
typename... _Args>
160 construct(_Up* __p, _Args&&... __args)
162 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
164 template<
typename _Up>
173 construct(pointer __p,
const _Tp& __val)
174 { ::new((
void *)__p) _Tp(__val); }
177 destroy(pointer __p) { __p->~_Tp(); }
181 template<
typename _Up>
182 friend _GLIBCXX20_CONSTEXPR
bool
187#if __cpp_impl_three_way_comparison < 201907L
188 template<
typename _Up>
189 friend _GLIBCXX20_CONSTEXPR
bool
196 _GLIBCXX_CONSTEXPR size_type
197 _M_max_size()
const _GLIBCXX_USE_NOEXCEPT
199#if __PTRDIFF_MAX__ < __SIZE_MAX__
200 return std::size_t(__PTRDIFF_MAX__) /
sizeof(_Tp);
202 return std::size_t(-1) /
sizeof(_Tp);
207_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
GNU extensions for public use.
An allocator that uses global new, as per C++03 [20.4.1].