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
45 template<
typename _Tp>
46 inline constexpr bool __is_pair =
false;
47 template<
typename _Tp,
typename _Up>
48 inline constexpr bool __is_pair<pair<_Tp, _Up>> =
true;
49 template<
typename _Tp,
typename _Up>
50 inline constexpr bool __is_pair<const pair<_Tp, _Up>> =
true;
52 template<
typename _Tp>
53 concept _Std_pair = __is_pair<_Tp>;
60#define __cpp_lib_make_obj_using_allocator 201811L
62 template<
typename _Tp,
typename _Alloc,
typename... _Args>
64 uses_allocator_construction_args(
const _Alloc& __a,
65 _Args&&... __args)
noexcept
66 requires (! _Std_pair<_Tp>)
68 if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
70 if constexpr (is_constructible_v<_Tp, allocator_arg_t,
71 const _Alloc&, _Args...>)
73 return tuple<allocator_arg_t,
const _Alloc&, _Args&&...>(
74 allocator_arg, __a, std::forward<_Args>(__args)...);
78 static_assert(is_constructible_v<_Tp, _Args...,
const _Alloc&>,
79 "construction with an allocator must be possible"
80 " if uses_allocator is true");
82 return tuple<_Args&&...,
const _Alloc&>(
83 std::forward<_Args>(__args)..., __a);
88 static_assert(is_constructible_v<_Tp, _Args...>);
90 return tuple<_Args&&...>(std::forward<_Args>(__args)...);
94 template<_Std_pair _Tp,
typename _Alloc,
typename _Tuple1,
typename _Tuple2>
96 uses_allocator_construction_args(
const _Alloc& __a, piecewise_construct_t,
97 _Tuple1&& __x, _Tuple2&& __y)
noexcept;
99 template<_Std_pair _Tp,
typename _Alloc>
101 uses_allocator_construction_args(
const _Alloc&)
noexcept;
103 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
105 uses_allocator_construction_args(
const _Alloc&, _Up&&, _Vp&&) noexcept;
107 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
109 uses_allocator_construction_args(const _Alloc&,
110 const pair<_Up, _Vp>&) noexcept;
112 template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
114 uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
116 template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2>
118 uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
119 _Tuple1&& __x, _Tuple2&& __y) noexcept
121 using _Tp1 =
typename _Tp::first_type;
122 using _Tp2 =
typename _Tp::second_type;
125 std::apply([&__a](
auto&&... __args1) {
126 return std::uses_allocator_construction_args<_Tp1>(
128 }, std::forward<_Tuple1>(__x)),
129 std::apply([&__a](
auto&&... __args2) {
130 return std::uses_allocator_construction_args<_Tp2>(
132 }, std::forward<_Tuple2>(__y)));
135 template<_Std_pair _Tp,
typename _Alloc>
137 uses_allocator_construction_args(
const _Alloc& __a)
noexcept
139 using _Tp1 =
typename _Tp::first_type;
140 using _Tp2 =
typename _Tp::second_type;
143 std::uses_allocator_construction_args<_Tp1>(__a),
144 std::uses_allocator_construction_args<_Tp2>(__a));
147 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
149 uses_allocator_construction_args(
const _Alloc& __a, _Up&& __u, _Vp&& __v)
152 using _Tp1 =
typename _Tp::first_type;
153 using _Tp2 =
typename _Tp::second_type;
156 std::uses_allocator_construction_args<_Tp1>(__a,
157 std::forward<_Up>(__u)),
158 std::uses_allocator_construction_args<_Tp2>(__a,
159 std::forward<_Vp>(__v)));
162 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
164 uses_allocator_construction_args(
const _Alloc& __a,
165 const pair<_Up, _Vp>& __pr)
noexcept
167 using _Tp1 =
typename _Tp::first_type;
168 using _Tp2 =
typename _Tp::second_type;
171 std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
172 std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
175 template<_Std_pair _Tp,
typename _Alloc,
typename _Up,
typename _Vp>
177 uses_allocator_construction_args(
const _Alloc& __a,
178 pair<_Up, _Vp>&& __pr)
noexcept
180 using _Tp1 =
typename _Tp::first_type;
181 using _Tp2 =
typename _Tp::second_type;
187 std::uses_allocator_construction_args<_Tp1>(__a,
189 std::uses_allocator_construction_args<_Tp2>(__a,
193 template<
typename _Tp,
typename _Alloc,
typename... _Args>
195 make_obj_using_allocator(
const _Alloc& __a, _Args&&... __args)
197 return std::make_from_tuple<_Tp>(
198 std::uses_allocator_construction_args<_Tp>(__a,
199 std::forward<_Args>(__args)...));
202 template<
typename _Tp,
typename _Alloc,
typename... _Args>
204 uninitialized_construct_using_allocator(_Tp* __p,
const _Alloc& __a,
207 return std::apply([&](
auto&&... __xs) {
208 return std::construct_at(__p,
std::forward<
decltype(__xs)>(__xs)...);
209 }, std::uses_allocator_construction_args<_Tp>(__a,
210 std::forward<_Args>(__args)...));
213_GLIBCXX_END_NAMESPACE_VERSION
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.