Skip to content

Commit

Permalink
Add workaround for clang bug (llvm/llvm-project#59827)
Browse files Browse the repository at this point in the history
  • Loading branch information
JMazurkiewicz committed Jan 4, 2023
1 parent 6a83047 commit cdcf2b9
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ concept _Tuple_like = _Tuple_like_impl<remove_cvref_t<_Ty>>;

template <class _Ty>
concept _Pair_like = _Tuple_like<_Ty> && tuple_size_v<remove_cvref_t<_Ty>> == 2;

#ifdef __clang__ // TRANSITION, LLVM-59827
template <class _PairLike, class _Ty1, class _Ty2>
concept _Can_construct_from_pair_like =
_Pair_like<_PairLike> && is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))>
&& is_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_PairLike>()))>;
#endif // __clang__
#endif // _HAS_CXX23
#endif // __cpp_lib_concepts

Expand Down Expand Up @@ -270,17 +277,19 @@ struct pair { // store a pair of values
: first(_STD forward<const _Other1>(_Right.first)), second(_STD forward<const _Other2>(_Right.second)) {}

#ifdef __cpp_lib_concepts
// clang-format off
#ifdef __clang__ // TRANSITION, LLVM-59827
template <class _Other, enable_if_t<_Can_construct_from_pair_like<_Other, _Ty1, _Ty2>, int> = 0>
#else // ^^^ workaround / no workaround vvv
template <_Pair_like _Other>
requires conjunction_v<is_constructible<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>,
is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>>
is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>>
#endif // __clang__
constexpr explicit(!conjunction_v<is_convertible<decltype(_STD get<0>(_STD declval<_Other>())), _Ty1>,
is_convertible<decltype(_STD get<1>(_STD declval<_Other>())), _Ty2>>)
pair(_Other&& _Right)
noexcept(is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))> &&
is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened
: first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) {}
// clang-format on
is_convertible<decltype(_STD get<1>(_STD declval<_Other>())), _Ty2>>)
pair(_Other&& _Right) noexcept(is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>&&
is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened
: first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) {
}
#endif // __cpp_lib_concepts
#endif // _HAS_CXX23

Expand Down

0 comments on commit cdcf2b9

Please sign in to comment.