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 (__n > this->_M_max_size())
106 std::__throw_bad_alloc();
108 #if __cpp_aligned_new
109 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
111 std::align_val_t __al = std::align_val_t(
alignof(_Tp));
112 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp), __al));
115 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
120 deallocate(_Tp* __p, size_type __t)
122 #if __cpp_aligned_new
123 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
125 ::operator
delete(__p,
126 # if __cpp_sized_deallocation
129 std::align_val_t(
alignof(_Tp)));
133 ::operator
delete(__p
134 #if __cpp_sized_deallocation
140 #if __cplusplus <= 201703L
142 max_size()
const _GLIBCXX_USE_NOEXCEPT
143 {
return _M_max_size(); }
145 #if __cplusplus >= 201103L
146 template<
typename _Up,
typename... _Args>
148 construct(_Up* __p, _Args&&... __args)
150 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
152 template<
typename _Up>
161 construct(pointer __p,
const _Tp& __val)
162 { ::new((
void *)__p) _Tp(__val); }
165 destroy(pointer __p) { __p->~_Tp(); }
169 template<
typename _Up>
170 friend _GLIBCXX20_CONSTEXPR
bool
175 #if __cpp_impl_three_way_comparison < 201907L
176 template<
typename _Up>
177 friend _GLIBCXX20_CONSTEXPR
bool
184 _GLIBCXX_CONSTEXPR size_type
185 _M_max_size()
const _GLIBCXX_USE_NOEXCEPT
187 #if __PTRDIFF_MAX__ < __SIZE_MAX__
188 return std::size_t(__PTRDIFF_MAX__) /
sizeof(_Tp);
190 return std::size_t(-1) /
sizeof(_Tp);
195 _GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
An allocator that uses global new, as per [20.4].This is precisely the allocator defined in the C++ S...