30 #ifndef _USES_ALLOCATOR_ARGS
31 #define _USES_ALLOCATOR_ARGS 1
33 #ifdef _GLIBCXX_SYSHDR
34 #pragma GCC system_header
39 #ifdef __glibcxx_make_obj_using_allocator
45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Tp>
50 concept _Std_pair = __is_pair<remove_cv_t<_Tp>>;
55 template<
typename _Tp,
typename _Alloc,
typename... _Args>
57 uses_allocator_construction_args(
const _Alloc& __a,
58 _Args&&... __args) noexcept
59 requires (! _Std_pair<_Tp>)
61 if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
63 if constexpr (is_constructible_v<_Tp, allocator_arg_t,
64 const _Alloc&, _Args...>)
66 return tuple<allocator_arg_t,
const _Alloc&, _Args&&...>(
67 allocator_arg, __a, std::forward<_Args>(__args)...);
71 static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>,
72 "construction with an allocator must be possible"
73 " if uses_allocator is true");
75 return tuple<_Args&&...,
const _Alloc&>(
76 std::forward<_Args>(__args)..., __a);
81 static_assert(is_constructible_v<_Tp, _Args...>);
83 return tuple<_Args&&...>(std::forward<_Args>(__args)...);
87 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
89 uses_allocator_construction_args(
const _Alloc& __a, piecewise_construct_t,
90 _Tuple1&& __x, _Tuple2&& __y) noexcept;
92 template<_Std_pair _Tp,
typename _Alloc>
94 uses_allocator_construction_args(
const _Alloc&) noexcept;
96 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
98 uses_allocator_construction_args(
const _Alloc&, _Up&&, _Vp&&) noexcept;
100 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
102 uses_allocator_construction_args(const _Alloc&,
103 const pair<_Up, _Vp>&) noexcept;
105 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
107 uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
109 #if __cplusplus > 202002L
110 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
112 uses_allocator_construction_args(
const _Alloc&,
113 pair<_Up, _Vp>&) noexcept;
115 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
117 uses_allocator_construction_args(
const _Alloc&,
const pair<_Up, _Vp>&&) noexcept;
120 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
122 uses_allocator_construction_args(
const _Alloc& __a, piecewise_construct_t,
123 _Tuple1&& __x, _Tuple2&& __y) noexcept
125 using _Tp1 =
typename _Tp::first_type;
126 using _Tp2 =
typename _Tp::second_type;
129 std::apply([&__a](
auto&&... __args1) {
130 return std::uses_allocator_construction_args<_Tp1>(
132 }, std::forward<_Tuple1>(__x)),
133 std::apply([&__a](
auto&&... __args2) {
134 return std::uses_allocator_construction_args<_Tp2>(
136 }, std::forward<_Tuple2>(__y)));
139 template<_Std_pair _Tp,
typename _Alloc>
141 uses_allocator_construction_args(
const _Alloc& __a) noexcept
143 using _Tp1 =
typename _Tp::first_type;
144 using _Tp2 =
typename _Tp::second_type;
147 std::uses_allocator_construction_args<_Tp1>(__a),
148 std::uses_allocator_construction_args<_Tp2>(__a));
151 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
153 uses_allocator_construction_args(
const _Alloc& __a, _Up&& __u, _Vp&& __v)
156 using _Tp1 =
typename _Tp::first_type;
157 using _Tp2 =
typename _Tp::second_type;
160 std::uses_allocator_construction_args<_Tp1>(__a,
161 std::forward<_Up>(__u)),
162 std::uses_allocator_construction_args<_Tp2>(__a,
163 std::forward<_Vp>(__v)));
166 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
168 uses_allocator_construction_args(
const _Alloc& __a,
169 const pair<_Up, _Vp>& __pr) noexcept
171 using _Tp1 =
typename _Tp::first_type;
172 using _Tp2 =
typename _Tp::second_type;
175 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
176 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
179 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
181 uses_allocator_construction_args(
const _Alloc& __a,
182 pair<_Up, _Vp>&& __pr) noexcept
184 using _Tp1 =
typename _Tp::first_type;
185 using _Tp2 =
typename _Tp::second_type;
191 std::uses_allocator_construction_args<_Tp1>(__a,
193 std::uses_allocator_construction_args<_Tp2>(__a,
197 #if __cplusplus > 202002L
198 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
200 uses_allocator_construction_args(
const _Alloc& __a,
201 pair<_Up, _Vp>& __pr) noexcept
203 using _Tp1 =
typename _Tp::first_type;
204 using _Tp2 =
typename _Tp::second_type;
207 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
208 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
211 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
213 uses_allocator_construction_args(
const _Alloc& __a,
214 const pair<_Up, _Vp>&& __pr) noexcept
216 using _Tp1 =
typename _Tp::first_type;
217 using _Tp2 =
typename _Tp::second_type;
220 std::uses_allocator_construction_args<_Tp1>(__a,
222 std::uses_allocator_construction_args<_Tp2>(__a,
227 template<
typename _Tp,
typename _Alloc,
typename... _Args>
229 make_obj_using_allocator(
const _Alloc& __a, _Args&&... __args)
231 return std::make_from_tuple<_Tp>(
232 std::uses_allocator_construction_args<_Tp>(__a,
233 std::forward<_Args>(__args)...));
236 template<
typename _Tp,
typename _Alloc,
typename... _Args>
238 uninitialized_construct_using_allocator(_Tp* __p,
const _Alloc& __a,
241 return std::apply([&](
auto&&... __xs) {
242 return std::construct_at(__p,
std::forward<decltype(__xs)>(__xs)...);
243 }, std::uses_allocator_construction_args<_Tp>(__a,
244 std::forward<_Args>(__args)...));
247 _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 tuple< typename __decay_and_strip< _Elements >::__type... > make_tuple(_Elements &&... __args)
Create a tuple containing copies of the arguments.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.