30#ifndef _GLIBCXX_MEMORY_RESOURCE_H
31#define _GLIBCXX_MEMORY_RESOURCE_H 1
34#pragma GCC system_header
37#if __cplusplus >= 201703L
42#include <bits/uses_allocator.h>
47#if ! __glibcxx_make_obj_using_allocator
52namespace std _GLIBCXX_VISIBILITY(default)
54_GLIBCXX_BEGIN_NAMESPACE_VERSION
65 static constexpr size_t _S_max_align =
alignof(
max_align_t);
88 {
return do_is_equal(__other); }
104 {
return &__a == &__b || __a.is_equal(__b); }
106#if __cpp_impl_three_way_comparison < 201907L
109 operator!=(
const memory_resource& __a,
const memory_resource& __b)
noexcept
110 {
return !(__a == __b); }
121 template<
typename _Tp>
126 template<
typename _Up>
127 struct __not_pair {
using type =
void; };
129 template<
typename _Up1,
typename _Up2>
133 using value_type = _Tp;
145 { _GLIBCXX_DEBUG_ASSERT(__r); }
149 template<
typename _Up>
151 : _M_resource(__x.resource())
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
171 { _M_resource->deallocate(__p, __n *
sizeof(_Tp),
alignof(_Tp)); }
173#ifdef __glibcxx_polymorphic_allocator
180 deallocate_bytes(
void* __p,
size_t __nbytes,
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>
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>
244 template<
typename _Tp1,
typename _Tp2,
263 template<
typename _Tp1,
typename _Tp2>
269 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
279 template <
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
289 template<
typename _Tp1,
typename _Tp2,
typename _Up,
typename _Vp>
299 template<
typename _Tp1,
typename...
_Args>
304 std::uninitialized_construct_using_allocator(__p, *
this,
309 template<
typename _Up>
316 select_on_container_copy_construction()
const noexcept
320 resource()
const noexcept
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
345 template<
typename _Ind,
typename...
_Args>
350 template<
size_t...
_Ind,
typename...
_Args>
360 template<
size_t...
_Ind,
typename...
_Args>
370 template<
typename _Tp1,
typename _Tp2>
375 {
return *__a.resource() == *__b.resource(); }
377#if __cpp_impl_three_way_comparison < 201907L
378 template<
typename _Tp1,
typename _Tp2>
383 {
return !(__a == __b); }
388 template<
typename _Alloc>
struct allocator_traits;
396 template<
typename _Tp>
439 template<
typename _Up>
442 template<
typename _Up>
454 {
return __a.allocate(__n); }
469 {
return __a.allocate(__n); }
481 { __a.deallocate(__p, __n); }
494 template<
typename _Up,
typename...
_Args>
506 template<
typename _Up>
521_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.