126 template<
typename _Up>
127 struct __not_pair {
using type = void; };
129 template<
typename _Up1,
typename _Up2>
130 struct __not_pair<
pair<_Up1, _Up2>> { };
133 using value_type = _Tp;
138 __attribute__((__returns_nonnull__));
143 __attribute__((__nonnull__))
145 { _GLIBCXX_DEBUG_ASSERT(__r); }
149 template<
typename _Up>
151 : _M_resource(__x.resource())
160 __attribute__((__returns_nonnull__))
163 std::__throw_bad_array_new_length();
164 return static_cast<_Tp*
>(_M_resource->allocate(__n *
sizeof(_Tp),
169 deallocate(_Tp* __p,
size_t __n)
noexcept
170 __attribute__((__nonnull__))
171 { _M_resource->deallocate(__p, __n *
sizeof(_Tp),
alignof(_Tp)); }
173#ifdef __glibcxx_polymorphic_allocator
175 allocate_bytes(
size_t __nbytes,
176 size_t __alignment =
alignof(max_align_t))
177 {
return _M_resource->allocate(__nbytes, __alignment); }
180 deallocate_bytes(
void* __p,
size_t __nbytes,
181 size_t __alignment =
alignof(max_align_t))
182 { _M_resource->deallocate(__p, __nbytes, __alignment); }
184 template<
typename _Up>
186 allocate_object(
size_t __n = 1)
189 std::__throw_bad_array_new_length();
190 return static_cast<_Up*
>(allocate_bytes(__n *
sizeof(_Up),
194 template<
typename _Up>
196 deallocate_object(_Up* __p,
size_t __n = 1)
197 { deallocate_bytes(__p, __n *
sizeof(_Up),
alignof(_Up)); }
199 template<
typename _Up,
typename... _CtorArgs>
201 new_object(_CtorArgs&&... __ctor_args)
203 _Up* __p = allocate_object<_Up>();
206 construct(__p, std::forward<_CtorArgs>(__ctor_args)...);
210 deallocate_object(__p);
211 __throw_exception_again;
216 template<
typename _Up>
218 delete_object(_Up* __p)
221 deallocate_object(__p);
225#if ! __glibcxx_make_obj_using_allocator
226 template<
typename _Tp1,
typename... _Args>
227 __attribute__((__nonnull__))
228 typename __not_pair<_Tp1>::type
229 construct(_Tp1* __p, _Args&&... __args)
235 if constexpr (is_base_of_v<__uses_alloc0, __use_tag>)
236 ::new(__p) _Tp1(std::forward<_Args>(__args)...);
237 else if constexpr (is_base_of_v<__uses_alloc1_, __use_tag>)
238 ::new(__p) _Tp1(allocator_arg, *
this,
239 std::forward<_Args>(__args)...);
241 ::new(__p) _Tp1(std::forward<_Args>(__args)..., *
this);
244 template<
typename _Tp1,
typename _Tp2,
245 typename... _Args1,
typename... _Args2>
246 __attribute__((__nonnull__))
259 _S_construct_p(__x_tag, __x_i, __x),
260 _S_construct_p(__y_tag, __y_i, __y));
263 template<
typename _Tp1,
typename _Tp2>
264 __attribute__((__nonnull__))
269 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
270 __attribute__((__nonnull__))
279 template <
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
280 __attribute__((__nonnull__))
289 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
290 __attribute__((__nonnull__))
299 template<
typename _Tp1,
typename... _Args>
300 __attribute__((__nonnull__))
302 construct(_Tp1* __p, _Args&&... __args)
304 std::uninitialized_construct_using_allocator(__p, *
this,
305 std::forward<_Args>(__args)...);
309 template<
typename _Up>
310 __attribute__((__nonnull__))
316 select_on_container_copy_construction()
const noexcept
320 resource()
const noexcept
321 __attribute__((__returns_nonnull__))
322 {
return _M_resource; }
330 {
return *__a.resource() == *__b.resource(); }
332#if __cpp_impl_three_way_comparison < 201907L
337 {
return !(__a == __b); }
341#if ! __glibcxx_make_obj_using_allocator
342 using __uses_alloc1_ = __uses_alloc1<polymorphic_allocator>;
343 using __uses_alloc2_ = __uses_alloc2<polymorphic_allocator>;
345 template<
typename _Ind,
typename... _Args>
346 static tuple<_Args&&...>
350 template<
size_t... _Ind,
typename... _Args>
356 allocator_arg, *__ua._M_a, std::get<_Ind>(
std::move(__t))...
360 template<
size_t... _Ind,
typename... _Args>
364 {
return { std::get<_Ind>(
std::move(__t))..., *__ua._M_a }; }