30#ifndef _USES_ALLOCATOR_ARGS
31#define _USES_ALLOCATOR_ARGS 1
33#pragma GCC system_header
35#if __cplusplus > 201703L && __cpp_concepts
42namespace std _GLIBCXX_VISIBILITY(default)
44_GLIBCXX_BEGIN_NAMESPACE_VERSION
46 template<
typename _Tp>
47 concept _Std_pair = __is_pair<remove_cv_t<_Tp>>;
54#define __cpp_lib_make_obj_using_allocator 201811L
56 template<
typename _Tp,
typename _Alloc,
typename... _Args>
58 uses_allocator_construction_args(
const _Alloc& __a,
59 _Args&&... __args)
noexcept
60 requires (! _Std_pair<_Tp>)
62 if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
64 if constexpr (is_constructible_v<_Tp, allocator_arg_t,
65 const _Alloc&, _Args...>)
67 return tuple<allocator_arg_t,
const _Alloc&, _Args&&...>(
72 static_assert(is_constructible_v<_Tp, _Args...,
const _Alloc&>,
73 "construction with an allocator must be possible"
74 " if uses_allocator is true");
76 return tuple<_Args&&...,
const _Alloc&>(
82 static_assert(is_constructible_v<_Tp, _Args...>);
88 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
91 _Tuple1&& __x, _Tuple2&& __y)
noexcept;
93 template<_Std_pair _Tp,
typename _Alloc>
95 uses_allocator_construction_args(
const _Alloc&)
noexcept;
97 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
99 uses_allocator_construction_args(
const _Alloc&, _Up&&, _Vp&&) noexcept;
101 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
103 uses_allocator_construction_args(const _Alloc&,
104 const
pair<_Up, _Vp>&) noexcept;
106 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
108 uses_allocator_construction_args(const _Alloc&,
pair<_Up, _Vp>&&) noexcept;
110#if __cplusplus > 202002L
111 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
113 uses_allocator_construction_args(
const _Alloc&,
116 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
118 uses_allocator_construction_args(
const _Alloc&,
const pair<_Up, _Vp>&&) noexcept;
121 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
124 _Tuple1&& __x, _Tuple2&& __y)
noexcept
126 using _Tp1 =
typename _Tp::first_type;
127 using _Tp2 =
typename _Tp::second_type;
130 std::apply([&__a](
auto&&... __args1) {
131 return std::uses_allocator_construction_args<_Tp1>(
134 std::apply([&__a](
auto&&... __args2) {
135 return std::uses_allocator_construction_args<_Tp2>(
140 template<_Std_pair _Tp,
typename _Alloc>
142 uses_allocator_construction_args(
const _Alloc& __a)
noexcept
144 using _Tp1 =
typename _Tp::first_type;
145 using _Tp2 =
typename _Tp::second_type;
148 std::uses_allocator_construction_args<_Tp1>(__a),
149 std::uses_allocator_construction_args<_Tp2>(__a));
152 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
154 uses_allocator_construction_args(
const _Alloc& __a, _Up&& __u, _Vp&& __v)
157 using _Tp1 =
typename _Tp::first_type;
158 using _Tp2 =
typename _Tp::second_type;
161 std::uses_allocator_construction_args<_Tp1>(__a,
163 std::uses_allocator_construction_args<_Tp2>(__a,
167 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
169 uses_allocator_construction_args(
const _Alloc& __a,
172 using _Tp1 =
typename _Tp::first_type;
173 using _Tp2 =
typename _Tp::second_type;
176 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
177 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
180 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
182 uses_allocator_construction_args(
const _Alloc& __a,
185 using _Tp1 =
typename _Tp::first_type;
186 using _Tp2 =
typename _Tp::second_type;
192 std::uses_allocator_construction_args<_Tp1>(__a,
194 std::uses_allocator_construction_args<_Tp2>(__a,
198#if __cplusplus > 202002L
199 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
201 uses_allocator_construction_args(
const _Alloc& __a,
204 using _Tp1 =
typename _Tp::first_type;
205 using _Tp2 =
typename _Tp::second_type;
208 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
209 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
212 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
214 uses_allocator_construction_args(
const _Alloc& __a,
217 using _Tp1 =
typename _Tp::first_type;
218 using _Tp2 =
typename _Tp::second_type;
221 std::uses_allocator_construction_args<_Tp1>(__a,
223 std::uses_allocator_construction_args<_Tp2>(__a,
228 template<
typename _Tp,
typename _Alloc,
typename... _Args>
230 make_obj_using_allocator(
const _Alloc& __a, _Args&&... __args)
232 return std::make_from_tuple<_Tp>(
233 std::uses_allocator_construction_args<_Tp>(__a,
237 template<
typename _Tp,
typename _Alloc,
typename... _Args>
239 uninitialized_construct_using_allocator(_Tp* __p,
const _Alloc& __a,
242 return std::apply([&](
auto&&... __xs) {
243 return std::construct_at(__p,
std::forward<
decltype(__xs)>(__xs)...);
244 }, std::uses_allocator_construction_args<_Tp>(__a,
248_GLIBCXX_END_NAMESPACE_VERSION
constexpr tuple< typename __decay_and_strip< _Elements >::__type... > make_tuple(_Elements &&... __args)
Create a tuple containing copies of 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.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
Primary class template, tuple.
Struct holding two objects of arbitrary type.
Tag type for piecewise construction of std::pair objects.