@@ -273,6 +273,14 @@ struct pair { // store a pair of values
273
273
is_nothrow_constructible_v<_Ty1, _Other1> && is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
274
274
: first(_STD forward<_Other1>(_Val1)), second(_STD forward<_Other2>(_Val2)) {
275
275
}
276
+ #if _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
277
+ template <class _Other1 = _Ty1, class _Other2 = _Ty2,
278
+ enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
279
+ requires reference_constructs_from_temporary_v<_Ty1, _Other1&&>
280
+ || reference_constructs_from_temporary_v<_Ty2, _Other2&&>
281
+ explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
282
+ pair(_Other1&&, _Other2&&) = delete;
283
+ #endif // _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
276
284
277
285
pair(const pair&) = default;
278
286
pair(pair&&) = default;
@@ -284,6 +292,14 @@ struct pair { // store a pair of values
284
292
pair(pair<_Other1, _Other2>& _Right) noexcept(
285
293
is_nothrow_constructible_v<_Ty1, _Other1&> && is_nothrow_constructible_v<_Ty2, _Other2&>) // strengthened
286
294
: first(_Right.first), second(_Right.second) {}
295
+ #if _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
296
+ template <class _Other1, class _Other2>
297
+ requires is_constructible_v<_Ty1, _Other1&> && is_constructible_v<_Ty2, _Other2&>
298
+ && (reference_constructs_from_temporary_v<_Ty1, _Other1&>
299
+ || reference_constructs_from_temporary_v<_Ty2, _Other2&>)
300
+ explicit(!conjunction_v<is_convertible<_Other1&, _Ty1>, is_convertible<_Other2&, _Ty2>>)
301
+ pair(pair<_Other1, _Other2>&) = delete;
302
+ #endif // _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
287
303
#endif // _HAS_CXX23
288
304
289
305
template <class _Other1, class _Other2,
@@ -294,13 +310,30 @@ struct pair { // store a pair of values
294
310
noexcept(is_nothrow_constructible_v<_Ty1, const _Other1&>
295
311
&& is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened
296
312
: first(_Right.first), second(_Right.second) {}
313
+ #if _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
314
+ template <class _Other1, class _Other2,
315
+ enable_if_t<conjunction_v<is_constructible<_Ty1, const _Other1&>, is_constructible<_Ty2, const _Other2&>>,
316
+ int> = 0>
317
+ requires reference_constructs_from_temporary_v<_Ty1, const _Other1&>
318
+ || reference_constructs_from_temporary_v<_Ty2, const _Other2&>
319
+ explicit(!conjunction_v<is_convertible<const _Other1&, _Ty1>, is_convertible<const _Other2&, _Ty2>>)
320
+ pair(const pair<_Other1, _Other2>&) = delete;
321
+ #endif // _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
297
322
298
323
template <class _Other1, class _Other2,
299
324
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
300
325
constexpr explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
301
326
pair(pair<_Other1, _Other2>&& _Right) noexcept(
302
327
is_nothrow_constructible_v<_Ty1, _Other1> && is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
303
328
: first(_STD forward<_Other1>(_Right.first)), second(_STD forward<_Other2>(_Right.second)) {}
329
+ #if _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
330
+ template <class _Other1, class _Other2,
331
+ enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
332
+ requires reference_constructs_from_temporary_v<_Ty1, _Other1&&>
333
+ || reference_constructs_from_temporary_v<_Ty2, _Other2&&>
334
+ explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
335
+ pair(pair<_Other1, _Other2>&&) = delete;
336
+ #endif // _HAS_CXX23 && _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
304
337
305
338
#if _HAS_CXX23
306
339
template <class _Other1, class _Other2>
@@ -310,6 +343,14 @@ struct pair { // store a pair of values
310
343
noexcept(is_nothrow_constructible_v<_Ty1, const _Other1>
311
344
&& is_nothrow_constructible_v<_Ty2, const _Other2>) // strengthened
312
345
: first(_STD forward<const _Other1>(_Right.first)), second(_STD forward<const _Other2>(_Right.second)) {}
346
+ #if _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
347
+ template <class _Other1, class _Other2>
348
+ requires is_constructible_v<_Ty1, const _Other1> && is_constructible_v<_Ty2, const _Other2>
349
+ && (reference_constructs_from_temporary_v<_Ty1, const _Other1 &&>
350
+ || reference_constructs_from_temporary_v<_Ty2, const _Other2 &&>)
351
+ explicit(!conjunction_v<is_convertible<const _Other1, _Ty1>, is_convertible<const _Other2, _Ty2>>)
352
+ pair(const pair<_Other1, _Other2>&&) = delete;
353
+ #endif // _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
313
354
314
355
#ifdef __EDG__ // TRANSITION, VSO-1900279
315
356
template <class _Other, enable_if_t<_Can_construct_from_pair_like<_Other, _Ty1, _Ty2>, int> = 0>
@@ -324,6 +365,15 @@ struct pair { // store a pair of values
324
365
&& is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened
325
366
: first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) {
326
367
}
368
+ #if _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
369
+ template <_Pair_like_non_subrange _Other>
370
+ requires conjunction_v<is_constructible<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>,
371
+ is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>>
372
+ && (reference_constructs_from_temporary_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>
373
+ || reference_constructs_from_temporary_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>)
374
+ explicit(!conjunction_v<is_convertible<decltype(_STD get<0>(_STD declval<_Other>())), _Ty1>,
375
+ is_convertible<decltype(_STD get<1>(_STD declval<_Other>())), _Ty2>>) pair(_Other&&) = delete;
376
+ #endif // _HAS_REFERENCE_BINDING_TRAITS_INTRINSICS
327
377
#endif // _HAS_CXX23
328
378
329
379
template <class... _Types1, class... _Types2>
0 commit comments