44 #ifndef _USES_ALLOCATOR_ARGS
45 #define _USES_ALLOCATOR_ARGS 1
47 #pragma GCC system_header
49 #if __cplusplus > 201703L && __cpp_concepts
56 namespace std _GLIBCXX_VISIBILITY(default)
58 _GLIBCXX_BEGIN_NAMESPACE_VERSION
60 template<
typename _Tp>
61 concept _Std_pair = __is_pair<_Tp>;
68 #define __cpp_lib_make_obj_using_allocator 201811L
70 template<
typename _Tp,
typename _Alloc,
typename... _Args>
72 uses_allocator_construction_args(
const _Alloc& __a,
73 _Args&&... __args) noexcept
74 requires (! _Std_pair<_Tp>)
76 if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
78 if constexpr (is_constructible_v<_Tp, allocator_arg_t,
79 const _Alloc&, _Args...>)
81 return tuple<allocator_arg_t,
const _Alloc&, _Args&&...>(
82 allocator_arg, __a, std::forward<_Args>(__args)...);
86 static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>,
87 "construction with an allocator must be possible"
88 " if uses_allocator is true");
90 return tuple<_Args&&...,
const _Alloc&>(
91 std::forward<_Args>(__args)..., __a);
96 static_assert(is_constructible_v<_Tp, _Args...>);
98 return tuple<_Args&&...>(std::forward<_Args>(__args)...);
102 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
104 uses_allocator_construction_args(
const _Alloc& __a, piecewise_construct_t,
105 _Tuple1&& __x, _Tuple2&& __y) noexcept;
107 template<_Std_pair _Tp,
typename _Alloc>
109 uses_allocator_construction_args(
const _Alloc&) noexcept;
111 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
113 uses_allocator_construction_args(
const _Alloc&, _Up&&, _Vp&&) noexcept;
115 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
117 uses_allocator_construction_args(const _Alloc&,
118 const pair<_Up, _Vp>&) noexcept;
120 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
122 uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
124 template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2>
126 uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
127 _Tuple1&& __x, _Tuple2&& __y) noexcept
129 using _Tp1 =
typename _Tp::first_type;
130 using _Tp2 =
typename _Tp::second_type;
133 std::apply([&__a](
auto&&... __args1) {
134 return std::uses_allocator_construction_args<_Tp1>(
136 }, std::forward<_Tuple1>(__x)),
137 std::apply([&__a](
auto&&... __args2) {
138 return std::uses_allocator_construction_args<_Tp2>(
140 }, std::forward<_Tuple2>(__y)));
143 template<_Std_pair _Tp,
typename _Alloc>
145 uses_allocator_construction_args(
const _Alloc& __a) noexcept
147 using _Tp1 =
typename _Tp::first_type;
148 using _Tp2 =
typename _Tp::second_type;
151 std::uses_allocator_construction_args<_Tp1>(__a),
152 std::uses_allocator_construction_args<_Tp2>(__a));
155 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
157 uses_allocator_construction_args(
const _Alloc& __a, _Up&& __u, _Vp&& __v)
160 using _Tp1 =
typename _Tp::first_type;
161 using _Tp2 =
typename _Tp::second_type;
164 std::uses_allocator_construction_args<_Tp1>(__a,
165 std::forward<_Up>(__u)),
166 std::uses_allocator_construction_args<_Tp2>(__a,
167 std::forward<_Vp>(__v)));
170 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
172 uses_allocator_construction_args(
const _Alloc& __a,
173 const pair<_Up, _Vp>& __pr) noexcept
175 using _Tp1 =
typename _Tp::first_type;
176 using _Tp2 =
typename _Tp::second_type;
179 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
180 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
183 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
185 uses_allocator_construction_args(
const _Alloc& __a,
186 pair<_Up, _Vp>&& __pr) noexcept
188 using _Tp1 =
typename _Tp::first_type;
189 using _Tp2 =
typename _Tp::second_type;
192 std::uses_allocator_construction_args<_Tp1>(__a,
194 std::uses_allocator_construction_args<_Tp2>(__a,
198 template<
typename _Tp,
typename _Alloc,
typename... _Args>
200 make_obj_using_allocator(
const _Alloc& __a, _Args&&... __args)
202 return std::make_from_tuple<_Tp>(
203 std::uses_allocator_construction_args<_Tp>(__a,
204 std::forward<_Args>(__args)...));
207 template<
typename _Tp,
typename _Alloc,
typename... _Args>
209 uninitialized_construct_using_allocator(_Tp* __p,
const _Alloc& __a,
212 return std::apply([&](
auto&&... __xs) {
213 return std::construct_at(__p,
std::forward<decltype(__xs)>(__xs)...);
214 }, std::uses_allocator_construction_args<_Tp>(__a,
215 std::forward<_Args>(__args)...));
218 _GLIBCXX_END_NAMESPACE_VERSION
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.