Skip to content

Commit 5a2b58f

Browse files
committed
Change existing helpers to make them usable for the new overloads
1 parent f099e9c commit 5a2b58f

File tree

2 files changed

+47
-34
lines changed

2 files changed

+47
-34
lines changed

stl/inc/tuple

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ template <class... _Dests, class... _Srcs>
9191
_INLINE_VAR constexpr bool _Tuple_assignable_v0<true, tuple<_Dests...>, _Srcs...> =
9292
conjunction_v<is_assignable<_Dests&, _Srcs>...>; // note _Dests& instead of _Dests
9393

94+
#if _HAS_CXX23
95+
template <class... _Dests, class... _Srcs>
96+
_INLINE_VAR constexpr bool _Tuple_assignable_v0<true, const tuple<_Dests...>, _Srcs...> =
97+
conjunction_v<is_assignable<const _Dests&, _Srcs>...>;
98+
#endif // _HAS_CXX23
99+
94100
template <class _Dest, class... _Srcs>
95101
_INLINE_VAR constexpr bool _Tuple_assignable_v =
96102
_Tuple_assignable_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
@@ -105,27 +111,24 @@ template <class... _Dests, class... _Srcs>
105111
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v0<true, tuple<_Dests...>, _Srcs...> =
106112
conjunction_v<is_nothrow_assignable<_Dests&, _Srcs>...>; // note _Dests& instead of _Dests
107113

114+
#if _HAS_CXX23
115+
template <class... _Dests, class... _Srcs>
116+
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v0<true, const tuple<_Dests...>, _Srcs...> =
117+
conjunction_v<is_nothrow_assignable<const _Dests&, _Srcs>...>;
118+
#endif // _HAS_CXX23
119+
108120
template <class _Dest, class... _Srcs>
109121
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v =
110122
_Tuple_nothrow_assignable_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
111123

112-
// Constrain tuple's copy converting constructor (LWG-2549)
113-
template <class _Myself, class... _Other>
114-
struct _Tuple_convert_copy_val : true_type {};
115-
116-
template <class _This, class _Uty>
117-
struct _Tuple_convert_copy_val<tuple<_This>, _Uty>
118-
: bool_constant<!disjunction_v<is_same<_This, _Uty>, is_constructible<_This, const tuple<_Uty>&>,
119-
is_convertible<const tuple<_Uty>&, _This>>> {};
120-
121-
// Constrain tuple's move converting constructor (LWG-2549)
122-
template <class _Myself, class... _Other>
123-
struct _Tuple_convert_move_val : true_type {};
124+
// Constrain tuple's converting constructors
125+
template <class _Myself, class _OtherTuple, class... _Other>
126+
struct _Tuple_convert_val : true_type {};
124127

125-
template <class _This, class _Uty>
126-
struct _Tuple_convert_move_val<tuple<_This>, _Uty>
127-
: bool_constant<!disjunction_v<is_same<_This, _Uty>, is_constructible<_This, tuple<_Uty>>,
128-
is_convertible<tuple<_Uty>, _This>>> {};
128+
template <class _This, class _OtherTuple, class _Uty>
129+
struct _Tuple_convert_val<tuple<_This>, _OtherTuple, _Uty>
130+
: bool_constant<!disjunction_v<is_same<_This, _Uty>, is_constructible<_This, _OtherTuple>,
131+
is_convertible<_OtherTuple, _This>>> {};
129132

130133
// Constrain tuple's perfect forwarding constructor (LWG-3121)
131134
template <class _Myself, class _This2, class... _Rest2>
@@ -348,22 +351,22 @@ public:
348351

349352
#if _HAS_CONDITIONAL_EXPLICIT
350353
template <class... _Other, enable_if_t<conjunction_v<_STD _Tuple_constructible_val<tuple, const _Other&...>,
351-
_STD _Tuple_convert_copy_val<tuple, _Other...>>,
354+
_STD _Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
352355
int> = 0>
353356
constexpr explicit(_Tuple_conditional_explicit_v<tuple, const _Other&...>)
354357
tuple(const tuple<_Other...>& _Right) noexcept(
355358
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
356359
: tuple(_Unpack_tuple_t{}, _Right) {}
357360
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
358361
template <class... _Other, enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, const _Other&...>,
359-
_Tuple_convert_copy_val<tuple, _Other...>>,
362+
_Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
360363
int> = 0>
361364
constexpr tuple(const tuple<_Other...>& _Right) noexcept(
362365
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
363366
: tuple(_Unpack_tuple_t{}, _Right) {}
364367

365368
template <class... _Other, enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, const _Other&...>,
366-
_Tuple_convert_copy_val<tuple, _Other...>>,
369+
_Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
367370
int> = 0>
368371
constexpr explicit tuple(const tuple<_Other...>& _Right) noexcept(
369372
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
@@ -372,22 +375,22 @@ public:
372375

373376
#if _HAS_CONDITIONAL_EXPLICIT
374377
template <class... _Other, enable_if_t<conjunction_v<_STD _Tuple_constructible_val<tuple, _Other...>,
375-
_STD _Tuple_convert_move_val<tuple, _Other...>>,
378+
_STD _Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
376379
int> = 0>
377380
constexpr explicit(_Tuple_conditional_explicit_v<tuple, _Other...>)
378381
tuple(tuple<_Other...>&& _Right) noexcept(_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
379382
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
380383
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
381-
template <class... _Other,
382-
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
383-
int> = 0>
384+
template <class... _Other, enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>,
385+
_Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
386+
int> = 0>
384387
constexpr tuple(tuple<_Other...>&& _Right) noexcept(
385388
_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
386389
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
387390

388-
template <class... _Other,
389-
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
390-
int> = 0>
391+
template <class... _Other, enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>,
392+
_Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
393+
int> = 0>
391394
constexpr explicit tuple(tuple<_Other...>&& _Right) noexcept(
392395
_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
393396
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
@@ -510,22 +513,22 @@ public:
510513
#if _HAS_CONDITIONAL_EXPLICIT
511514
template <class _Alloc, class... _Other,
512515
enable_if_t<conjunction_v<_STD _Tuple_constructible_val<tuple, const _Other&...>,
513-
_STD _Tuple_convert_copy_val<tuple, _Other...>>,
516+
_STD _Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
514517
int> = 0>
515518
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, const _Other&...>)
516519
tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
517520
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
518521
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
519522
template <class _Alloc, class... _Other,
520-
enable_if_t<
521-
conjunction_v<_Tuple_implicit_val<tuple, const _Other&...>, _Tuple_convert_copy_val<tuple, _Other...>>,
523+
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, const _Other&...>,
524+
_Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
522525
int> = 0>
523526
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
524527
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
525528

526529
template <class _Alloc, class... _Other,
527-
enable_if_t<
528-
conjunction_v<_Tuple_explicit_val<tuple, const _Other&...>, _Tuple_convert_copy_val<tuple, _Other...>>,
530+
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, const _Other&...>,
531+
_Tuple_convert_val<tuple, const tuple<_Other...>&, _Other...>>,
529532
int> = 0>
530533
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
531534
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
@@ -534,20 +537,22 @@ public:
534537
#if _HAS_CONDITIONAL_EXPLICIT
535538
template <class _Alloc, class... _Other,
536539
enable_if_t<conjunction_v<_STD _Tuple_constructible_val<tuple, _Other...>,
537-
_STD _Tuple_convert_move_val<tuple, _Other...>>,
540+
_STD _Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
538541
int> = 0>
539542
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, _Other...>)
540543
tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
541544
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
542545
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
543546
template <class _Alloc, class... _Other,
544-
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
547+
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>,
548+
_Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
545549
int> = 0>
546550
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
547551
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
548552

549553
template <class _Alloc, class... _Other,
550-
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
554+
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>,
555+
_Tuple_convert_val<tuple, tuple<_Other...>, _Other...>>,
551556
int> = 0>
552557
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
553558
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}

stl/inc/type_traits

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,14 @@ struct is_assignable : bool_constant<__is_assignable(_To, _From)> {}; // determi
649649
template <class _To, class _From>
650650
_INLINE_VAR constexpr bool is_assignable_v = __is_assignable(_To, _From);
651651

652+
#if defined(_IS_ASSIGNABLE_NOCHECK_SUPPORTED) && !defined(__CUDACC__)
653+
template <class _To, class _From>
654+
struct _Is_assignable_no_precondition_check : bool_constant<__is_assignable_no_precondition_check(_To, _From)> {};
655+
#else // ^^^ Use intrinsic / intrinsic not supported vvv
656+
template <class _To, class _From>
657+
using _Is_assignable_no_precondition_check = is_assignable<_To, _From>;
658+
#endif // defined(_IS_ASSIGNABLE_NOCHECK_SUPPORTED) && !defined(__CUDACC__)
659+
652660
template <class _Ty>
653661
struct is_copy_assignable
654662
: bool_constant<__is_assignable(add_lvalue_reference_t<_Ty>, add_lvalue_reference_t<const _Ty>)> {

0 commit comments

Comments
 (0)