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
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>
73#if __cplusplus >= 201103L
85 template<
typename _Tp1>
92 address(reference __x)
const _GLIBCXX_NOEXCEPT
96 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
101 _GLIBCXX_NODISCARD pointer
102 allocate(size_type __n,
const void* =
static_cast<const void*
>(0))
104 if (__n > this->max_size())
105 std::__throw_bad_alloc();
108 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
110 std::align_val_t __al = std::align_val_t(
alignof(_Tp));
111 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp), __al));
114 return static_cast<_Tp*
>(::operator
new(__n *
sizeof(_Tp)));
119 deallocate(pointer __p, size_type)
122 if (
alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
124 ::operator
delete(__p, std::align_val_t(
alignof(_Tp)));
128 ::operator
delete(__p);
132 max_size()
const _GLIBCXX_USE_NOEXCEPT
134#if __PTRDIFF_MAX__ < __SIZE_MAX__
135 return size_t(__PTRDIFF_MAX__) /
sizeof(_Tp);
137 return size_t(-1) /
sizeof(_Tp);
141#if __cplusplus >= 201103L
142 template<
typename _Up,
typename... _Args>
144 construct(_Up* __p, _Args&&... __args)
146 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
148 template<
typename _Up>
157 construct(pointer __p,
const _Tp& __val)
158 { ::new((
void *)__p) _Tp(__val); }
161 destroy(pointer __p) { __p->~_Tp(); }
164 template<
typename _Up>
170 template<
typename _Up>
177_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 [20.4].