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
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 (__n > this->_M_max_size())
112 std::__throw_bad_alloc();
114 #if __cpp_aligned_new
115 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
117 std::align_val_t __al = std::align_val_t(
alignof(_Tp));
118 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp), __al));
121 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
126 deallocate(_Tp* __p, size_type __t)
128 #if __cpp_aligned_new
129 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
131 ::operator
delete(__p,
132 # if __cpp_sized_deallocation
135 std::align_val_t(
alignof(_Tp)));
139 ::operator
delete(__p
140 #if __cpp_sized_deallocation
146 #if __cplusplus <= 201703L
148 max_size()
const _GLIBCXX_USE_NOEXCEPT
149 {
return _M_max_size(); }
151 #if __cplusplus >= 201103L
152 template<
typename _Up,
typename... _Args>
154 construct(_Up* __p, _Args&&... __args)
156 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
158 template<
typename _Up>
167 construct(pointer __p,
const _Tp& __val)
168 { ::new((
void *)__p) _Tp(__val); }
171 destroy(pointer __p) { __p->~_Tp(); }
175 template<
typename _Up>
176 friend _GLIBCXX20_CONSTEXPR
bool
181 #if __cpp_impl_three_way_comparison < 201907L
182 template<
typename _Up>
183 friend _GLIBCXX20_CONSTEXPR
bool
190 _GLIBCXX_CONSTEXPR size_type
191 _M_max_size()
const _GLIBCXX_USE_NOEXCEPT
193 #if __PTRDIFF_MAX__ < __SIZE_MAX__
194 return std::size_t(__PTRDIFF_MAX__) /
sizeof(_Tp);
196 return std::size_t(-1) /
sizeof(_Tp);
201 _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].