30#ifndef _GLIBCXX_MEMORY_RESOURCE_H
31#define _GLIBCXX_MEMORY_RESOURCE_H 1
33#pragma GCC system_header
35#if __cplusplus >= 201703L
40#include <bits/uses_allocator.h>
45#if ! __glibcxx_make_obj_using_allocator
50namespace std _GLIBCXX_VISIBILITY(default)
52_GLIBCXX_BEGIN_NAMESPACE_VERSION
63 static constexpr size_t _S_max_align =
alignof(
max_align_t);
86 {
return do_is_equal(__other); }
102 {
return &__a == &__b || __a.is_equal(__b); }
104#if __cpp_impl_three_way_comparison < 201907L
107 operator!=(
const memory_resource& __a,
const memory_resource& __b)
noexcept
108 {
return !(__a == __b); }
119 template<
typename _Tp>
124 template<
typename _Up>
125 struct __not_pair {
using type =
void; };
127 template<
typename _Up1,
typename _Up2>
131 using value_type = _Tp;
143 { _GLIBCXX_DEBUG_ASSERT(__r); }
147 template<
typename _Up>
149 : _M_resource(__x.resource())
161 std::__throw_bad_array_new_length();
162 return static_cast<_Tp*
>(_M_resource->allocate(__n *
sizeof(_Tp),
167 deallocate(_Tp* __p,
size_t __n)
noexcept
169 { _M_resource->deallocate(__p, __n *
sizeof(_Tp),
alignof(_Tp)); }
171#ifdef __glibcxx_polymorphic_allocator
178 deallocate_bytes(
void* __p,
size_t __nbytes,
182 template<
typename _Up>
184 allocate_object(
size_t __n = 1)
187 std::__throw_bad_array_new_length();
188 return static_cast<_Up*
>(allocate_bytes(__n *
sizeof(_Up),
192 template<
typename _Up>
194 deallocate_object(_Up* __p,
size_t __n = 1)
195 { deallocate_bytes(__p, __n *
sizeof(_Up),
alignof(_Up)); }
197 template<
typename _Up,
typename...
_CtorArgs>
208 deallocate_object(__p);
209 __throw_exception_again;
214 template<
typename _Up>
216 delete_object(_Up* __p)
219 deallocate_object(__p);
223#if ! __glibcxx_make_obj_using_allocator
224 template<
typename _Tp1,
typename...
_Args>
242 template<
typename _Tp1,
typename _Tp2,
261 template<
typename _Tp1,
typename _Tp2>
267 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
277 template <
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
287 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
297 template<
typename _Tp1,
typename...
_Args>
302 std::uninitialized_construct_using_allocator(__p, *
this,
307 template<
typename _Up>
314 select_on_container_copy_construction()
const noexcept
318 resource()
const noexcept
320 {
return _M_resource; }
328 {
return *__a.resource() == *__b.resource(); }
330#if __cpp_impl_three_way_comparison < 201907L
335 {
return !(__a == __b); }
339#if ! __glibcxx_make_obj_using_allocator
343 template<
typename _Ind,
typename...
_Args>
348 template<
size_t...
_Ind,
typename...
_Args>
358 template<
size_t...
_Ind,
typename...
_Args>
368 template<
typename _Tp1,
typename _Tp2>
373 {
return *__a.resource() == *__b.resource(); }
375#if __cpp_impl_three_way_comparison < 201907L
376 template<
typename _Tp1,
typename _Tp2>
381 {
return !(__a == __b); }
386 template<
typename _Alloc>
struct allocator_traits;
394 template<
typename _Tp>
437 template<
typename _Up>
440 template<
typename _Up>
452 {
return __a.allocate(__n); }
467 {
return __a.allocate(__n); }
479 { __a.deallocate(__p, __n); }
492 template<
typename _Up,
typename...
_Args>
504 template<
typename _Up>
519_GLIBCXX_END_NAMESPACE_VERSION
memory_resource * get_default_resource() noexcept
Get the current default memory resource pointer.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
Create a tuple of lvalue or rvalue references to the arguments.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
ISO C++ entities toplevel namespace is std.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
Primary class template, tuple.
Uniform interface to all allocator types.
__detected_or_t< value_type *, __pointer, _Alloc > pointer
The allocator's pointer type.
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
_Alloc::value_type value_type
The allocated type.
_Alloc allocator_type
The allocator type.
Class template polymorphic_allocator.
static void construct(allocator_type &__a, _Up *__p, _Args &&... __args)
Construct an object of type _Up
static void deallocate(allocator_type &__a, pointer __p, size_type __n)
Deallocate memory.
_Tp value_type
The allocated type.
static constexpr void destroy(allocator_type &, _Up *__p) noexcept(is_nothrow_destructible< _Up >::value)
Destroy an object of type _Up
static constexpr size_type max_size(const allocator_type &) noexcept
The maximum supported allocation size.
static pointer allocate(allocator_type &__a, size_type __n)
Allocate memory.
false_type propagate_on_container_swap
_Tp * pointer
The allocator's pointer type.
const _Tp * const_pointer
The allocator's const pointer type.
false_type propagate_on_container_move_assignment
static pointer allocate(allocator_type &__a, size_type __n, const_void_pointer)
Allocate memory.
false_type propagate_on_container_copy_assignment
static allocator_type select_on_container_copy_construction(const allocator_type &) noexcept
false_type is_always_equal
Whether all instances of the allocator type compare equal.
std::size_t size_type
The allocator's size type.
Struct holding two objects of arbitrary type.
Tag type for piecewise construction of std::pair objects.