@@ -134,12 +134,87 @@ struct uses_allocator : _Has_allocator_type<_Ty, _Alloc>::type {
134
134
_EXPORT_STD template <class _Ty, class _Alloc>
135
135
_INLINE_VAR constexpr bool uses_allocator_v = uses_allocator<_Ty, _Alloc>::value;
136
136
137
- _EXPORT_STD template <class...>
137
+ _EXPORT_STD template <class... _Types >
138
138
class tuple;
139
139
140
+ _EXPORT_STD template <class _Ty1, class _Ty2>
141
+ struct pair;
142
+
143
+ _EXPORT_STD template <class _Ty, size_t _Size>
144
+ class array;
145
+
146
+ _EXPORT_STD template <class _Tuple>
147
+ struct tuple_size;
148
+
149
+ _EXPORT_STD template <class _Ty>
150
+ _INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Ty>::value;
151
+
152
+ _EXPORT_STD template <size_t _Index, class _Tuple>
153
+ struct tuple_element;
154
+
155
+ _EXPORT_STD template <size_t _Index, class _Tuple>
156
+ using tuple_element_t = typename tuple_element<_Index, _Tuple>::type;
157
+
140
158
_EXPORT_STD /* TRANSITION, VSO-1538698 */ template <size_t _Index, class... _Types>
141
159
_NODISCARD constexpr auto&& _Tuple_get(tuple<_Types...>&& _Tuple) noexcept;
142
160
161
+ _EXPORT_STD template <size_t _Index, class... _Types>
162
+ _NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>& get(tuple<_Types...>& _Tuple) noexcept;
163
+
164
+ _EXPORT_STD template <size_t _Index, class... _Types>
165
+ _NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>& get(const tuple<_Types...>& _Tuple) noexcept;
166
+
167
+ _EXPORT_STD template <size_t _Index, class... _Types>
168
+ _NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>&& get(tuple<_Types...>&& _Tuple) noexcept;
169
+
170
+ _EXPORT_STD template <size_t _Index, class... _Types>
171
+ _NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const tuple<_Types...>&& _Tuple) noexcept;
172
+
173
+ _EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
174
+ _NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept;
175
+
176
+ _EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
177
+ _NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept;
178
+
179
+ _EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
180
+ _NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept;
181
+
182
+ _EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
183
+ _NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept;
184
+
185
+ #ifdef __cpp_lib_concepts
186
+ template <class _Ty1, class _Ty2>
187
+ concept _Different_from = (!same_as<remove_cvref_t<_Ty1>, remove_cvref_t<_Ty2>>);
188
+
189
+ template <class>
190
+ inline constexpr bool _Is_std_array_v = false;
191
+
192
+ template <class _Ty, size_t _Size>
193
+ inline constexpr bool _Is_std_array_v<array<_Ty, _Size>> = true;
194
+
195
+ template <class>
196
+ inline constexpr bool _Is_subrange_v = false;
197
+
198
+ #if _HAS_CXX23
199
+ template <class _Ty>
200
+ inline constexpr bool _Tuple_like_impl =
201
+ _Is_specialization_v<_Ty, tuple> || _Is_specialization_v<_Ty, pair> || _Is_std_array_v<_Ty> || _Is_subrange_v<_Ty>;
202
+
203
+ template <class _Ty>
204
+ concept _Tuple_like = _Tuple_like_impl<remove_cvref_t<_Ty>>;
205
+
206
+ template <class _Ty>
207
+ concept _Pair_like = _Tuple_like<_Ty> && tuple_size_v<remove_cvref_t<_Ty>> == 2;
208
+
209
+ #ifdef __clang__ // TRANSITION, LLVM-59827
210
+ template <class _PairLike, class _Ty1, class _Ty2>
211
+ concept _Can_construct_from_pair_like =
212
+ _Pair_like<_PairLike> && is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))>
213
+ && is_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_PairLike>()))>;
214
+ #endif // __clang__
215
+ #endif // _HAS_CXX23
216
+ #endif // __cpp_lib_concepts
217
+
143
218
_EXPORT_STD template <class _Ty1, class _Ty2>
144
219
struct pair { // store a pair of values
145
220
using first_type = _Ty1;
@@ -207,6 +282,22 @@ struct pair { // store a pair of values
207
282
pair(const pair<_Other1, _Other2>&& _Right) noexcept(is_nothrow_constructible_v<_Ty1, const _Other1>&&
208
283
is_nothrow_constructible_v<_Ty2, const _Other2>) // strengthened
209
284
: first(_STD forward<const _Other1>(_Right.first)), second(_STD forward<const _Other2>(_Right.second)) {}
285
+
286
+ #ifdef __cpp_lib_concepts
287
+ #ifdef __clang__ // TRANSITION, LLVM-59827
288
+ template <class _Other, enable_if_t<_Can_construct_from_pair_like<_Other, _Ty1, _Ty2>, int> = 0>
289
+ #else // ^^^ workaround / no workaround vvv
290
+ template <_Pair_like _Other>
291
+ requires conjunction_v<is_constructible<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>,
292
+ is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>>
293
+ #endif // __clang__
294
+ constexpr explicit(!conjunction_v<is_convertible<decltype(_STD get<0>(_STD declval<_Other>())), _Ty1>,
295
+ is_convertible<decltype(_STD get<1>(_STD declval<_Other>())), _Ty2>>)
296
+ pair(_Other&& _Right) noexcept(is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>&&
297
+ is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened
298
+ : first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) {
299
+ }
300
+ #endif // __cpp_lib_concepts
210
301
#endif // _HAS_CXX23
211
302
212
303
template <class _Tuple1, class _Tuple2, size_t... _Indexes1, size_t... _Indexes2>
@@ -318,6 +409,32 @@ struct pair { // store a pair of values
318
409
second = _STD forward<_Other2>(_Right.second);
319
410
return *this;
320
411
}
412
+
413
+ #ifdef __cpp_lib_concepts
414
+ template <_Pair_like _Other>
415
+ requires _Different_from<_Other, pair> && (!_Is_subrange_v<remove_cvref_t<_Other>>)
416
+ && is_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
417
+ && is_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>
418
+ constexpr pair& operator=(_Other&& _Right) noexcept(
419
+ is_nothrow_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>&&
420
+ is_nothrow_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ {
421
+ first = _STD get<0>(_STD forward<_Other>(_Right));
422
+ second = _STD get<1>(_STD forward<_Other>(_Right));
423
+ return *this;
424
+ }
425
+
426
+ template <_Pair_like _Other>
427
+ requires _Different_from<_Other, pair> && (!_Is_subrange_v<remove_cvref_t<_Other>>)
428
+ && is_assignable_v<const _Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
429
+ && is_assignable_v<const _Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>
430
+ constexpr const pair& operator=(_Other&& _Right) const noexcept(
431
+ is_nothrow_assignable_v<const _Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>&&
432
+ is_nothrow_assignable_v<const _Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ {
433
+ first = _STD get<0>(_STD forward<_Other>(_Right));
434
+ second = _STD get<1>(_STD forward<_Other>(_Right));
435
+ return *this;
436
+ }
437
+ #endif // __cpp_lib_concepts
321
438
#endif // _HAS_CXX23
322
439
323
440
_CONSTEXPR20 void swap(pair& _Right) noexcept(
@@ -469,9 +586,6 @@ namespace _CXX20_DEPRECATE_REL_OPS rel_ops {
469
586
}
470
587
} // namespace _CXX20_DEPRECATE_REL_OPS rel_ops
471
588
472
- _EXPORT_STD template <class _Tuple>
473
- struct tuple_size;
474
-
475
589
template <class _Tuple, class = void>
476
590
struct _Tuple_size_sfinae {}; // selected when tuple_size<_Tuple>::value isn't well-formed
477
591
@@ -488,12 +602,6 @@ struct _CXX20_DEPRECATE_VOLATILE tuple_size<volatile _Tuple> : _Tuple_size_sfina
488
602
template <class _Tuple>
489
603
struct _CXX20_DEPRECATE_VOLATILE tuple_size<const volatile _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv
490
604
491
- _EXPORT_STD template <class _Ty>
492
- _INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Ty>::value;
493
-
494
- _EXPORT_STD template <size_t _Index, class _Tuple>
495
- struct tuple_element;
496
-
497
605
template <size_t _Index, class _Tuple>
498
606
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Index, const _Tuple> : tuple_element<_Index, _Tuple> {
499
607
using _Mybase = tuple_element<_Index, _Tuple>;
@@ -514,12 +622,6 @@ struct _CXX20_DEPRECATE_VOLATILE _MSVC_KNOWN_SEMANTICS tuple_element<_Index, con
514
622
using type = add_cv_t<typename _Mybase::type>;
515
623
};
516
624
517
- _EXPORT_STD template <size_t _Index, class _Tuple>
518
- using tuple_element_t = typename tuple_element<_Index, _Tuple>::type;
519
-
520
- _EXPORT_STD template <class _Ty, size_t _Size>
521
- class array;
522
-
523
625
template <class _Ty, size_t _Size>
524
626
struct tuple_size<array<_Ty, _Size>> : integral_constant<size_t, _Size> {}; // size of array
525
627
0 commit comments