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
59 template<
typename _Tp>
60 inline constexpr
bool __is_pair =
false;
61 template<
typename _Tp,
typename _Up>
62 inline constexpr
bool __is_pair<pair<_Tp, _Up>> =
true;
63 template<
typename _Tp,
typename _Up>
64 inline constexpr
bool __is_pair<const pair<_Tp, _Up>> =
true;
66 template<
typename _Tp>
67 concept _Std_pair = __is_pair<_Tp>;
74 #define __cpp_lib_make_obj_using_allocator 201811L
76 template<
typename _Tp,
typename _Alloc,
typename... _Args>
78 uses_allocator_construction_args(
const _Alloc& __a,
79 _Args&&... __args) noexcept
80 requires (! _Std_pair<_Tp>)
82 if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
84 if constexpr (is_constructible_v<_Tp, allocator_arg_t,
85 const _Alloc&, _Args...>)
87 return tuple<allocator_arg_t,
const _Alloc&, _Args&&...>(
88 allocator_arg, __a, std::forward<_Args>(__args)...);
92 static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>,
93 "construction with an allocator must be possible"
94 " if uses_allocator is true");
96 return tuple<_Args&&...,
const _Alloc&>(
97 std::forward<_Args>(__args)..., __a);
102 static_assert(is_constructible_v<_Tp, _Args...>);
104 return tuple<_Args&&...>(std::forward<_Args>(__args)...);
108 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
110 uses_allocator_construction_args(
const _Alloc& __a, piecewise_construct_t,
111 _Tuple1&& __x, _Tuple2&& __y) noexcept;
113 template<_Std_pair _Tp,
typename _Alloc>
115 uses_allocator_construction_args(
const _Alloc&) noexcept;
117 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
119 uses_allocator_construction_args(
const _Alloc&, _Up&&, _Vp&&) noexcept;
121 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
123 uses_allocator_construction_args(const _Alloc&,
124 const pair<_Up, _Vp>&) noexcept;
126 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
128 uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
130 template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2>
132 uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
133 _Tuple1&& __x, _Tuple2&& __y) noexcept
135 using _Tp1 =
typename _Tp::first_type;
136 using _Tp2 =
typename _Tp::second_type;
139 std::apply([&__a](
auto&&... __args1) {
140 return std::uses_allocator_construction_args<_Tp1>(
142 }, std::forward<_Tuple1>(__x)),
143 std::apply([&__a](
auto&&... __args2) {
144 return std::uses_allocator_construction_args<_Tp2>(
146 }, std::forward<_Tuple2>(__y)));
149 template<_Std_pair _Tp,
typename _Alloc>
151 uses_allocator_construction_args(
const _Alloc& __a) noexcept
153 using _Tp1 =
typename _Tp::first_type;
154 using _Tp2 =
typename _Tp::second_type;
157 std::uses_allocator_construction_args<_Tp1>(__a),
158 std::uses_allocator_construction_args<_Tp2>(__a));
161 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
163 uses_allocator_construction_args(
const _Alloc& __a, _Up&& __u, _Vp&& __v)
166 using _Tp1 =
typename _Tp::first_type;
167 using _Tp2 =
typename _Tp::second_type;
170 std::uses_allocator_construction_args<_Tp1>(__a,
171 std::forward<_Up>(__u)),
172 std::uses_allocator_construction_args<_Tp2>(__a,
173 std::forward<_Vp>(__v)));
176 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
178 uses_allocator_construction_args(
const _Alloc& __a,
179 const pair<_Up, _Vp>& __pr) noexcept
181 using _Tp1 =
typename _Tp::first_type;
182 using _Tp2 =
typename _Tp::second_type;
185 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
186 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
189 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
191 uses_allocator_construction_args(
const _Alloc& __a,
192 pair<_Up, _Vp>&& __pr) noexcept
194 using _Tp1 =
typename _Tp::first_type;
195 using _Tp2 =
typename _Tp::second_type;
198 std::uses_allocator_construction_args<_Tp1>(__a,
200 std::uses_allocator_construction_args<_Tp2>(__a,
204 template<
typename _Tp,
typename _Alloc,
typename... _Args>
206 make_obj_using_allocator(
const _Alloc& __a, _Args&&... __args)
208 return std::make_from_tuple<_Tp>(
209 std::uses_allocator_construction_args<_Tp>(__a,
210 std::forward<_Args>(__args)...));
213 template<
typename _Tp,
typename _Alloc,
typename... _Args>
215 uninitialized_construct_using_allocator(_Tp* __p,
const _Alloc& __a,
218 return std::apply([&](
auto&&... __xs) {
219 return std::construct_at(__p,
std::forward<decltype(__xs)>(__xs)...);
220 }, std::uses_allocator_construction_args<_Tp>(__a,
221 std::forward<_Args>(__args)...));
224 _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.