Skip to content

Commit

Permalink
Remove some workaround for Clang (#3722)
Browse files Browse the repository at this point in the history
Co-authored-by: Casey Carter <Casey@Carter.net>
  • Loading branch information
frederick-vs-ja and CaseyCarter authored May 30, 2023
1 parent 15dd2ab commit 29fccab
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 171 deletions.
79 changes: 2 additions & 77 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -2340,11 +2340,6 @@ namespace ranges {
_EXPORT_STD inline constexpr _Filter_fn filter;
} // namespace views

#ifdef __clang__
template <class _Rng, class _Fn> // TRANSITION, LLVM-47414
concept _Can_const_transform = range<const _Rng> && regular_invocable<const _Fn&, range_reference_t<const _Rng>>;
#endif // ^^^ workaround ^^^

_EXPORT_STD template <input_range _Vw, _Valid_movable_box_object _Fn>
requires view<_Vw> && regular_invocable<_Fn&, range_reference_t<_Vw>>
&& _Can_reference<invoke_result_t<_Fn&, range_reference_t<_Vw>>>
Expand Down Expand Up @@ -2708,11 +2703,7 @@ namespace ranges {

_NODISCARD constexpr _Iterator<true> begin() const noexcept(
noexcept(_RANGES begin(_Range)) && is_nothrow_move_constructible_v<iterator_t<_Vw>>) /* strengthened */
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_transform<_Vw, _Fn>
#else // ^^^ workaround / no workaround vvv
requires range<const _Vw> && regular_invocable<const _Fn&, range_reference_t<const _Vw>>
#endif // TRANSITION, LLVM-47414
{
return _Iterator<true>{*this, _RANGES begin(_Range)};
}
Expand All @@ -2731,11 +2722,7 @@ namespace ranges {
// clang-format off
_NODISCARD constexpr auto end() const noexcept(noexcept(
_RANGES end(_Range)) && is_nothrow_move_constructible_v<decltype(_RANGES end(_Range))>) /* strengthened */
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_transform<_Vw, _Fn>
#else // ^^^ workaround / no workaround vvv
requires range<const _Vw> && regular_invocable<const _Fn&, range_reference_t<const _Vw>>
#endif // TRANSITION, LLVM-47414
{
// clang-format on
if constexpr (common_range<_Vw>) {
Expand Down Expand Up @@ -3070,11 +3057,6 @@ namespace ranges {
_EXPORT_STD inline constexpr _Take_fn take;
} // namespace views

#ifdef __clang__
template <class _Vw, class _Pr> // TRANSITION, LLVM-47414
concept _Can_take_while_const = range<const _Vw> && indirect_unary_predicate<const _Pr, iterator_t<const _Vw>>;
#endif // ^^^ workaround ^^^

_EXPORT_STD template <view _Vw, class _Pr>
requires input_range<_Vw> && is_object_v<_Pr> && indirect_unary_predicate<const _Pr, iterator_t<_Vw>>
class take_while_view : public view_interface<take_while_view<_Vw, _Pr>> {
Expand Down Expand Up @@ -3190,11 +3172,7 @@ namespace ranges {
}

_NODISCARD constexpr auto begin() const noexcept(noexcept(_RANGES begin(_Range))) /* strengthened */
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_take_while_const<_Vw, _Pr>
#else // ^^^ workaround / no workaround vvv
requires range<const _Vw> && indirect_unary_predicate<const _Pr, iterator_t<const _Vw>>
#endif // TRANSITION, LLVM-47414
{
return _RANGES begin(_Range);
}
Expand All @@ -3211,11 +3189,7 @@ namespace ranges {

_NODISCARD constexpr auto end() const noexcept(
noexcept(_RANGES end(_Range)) && is_nothrow_move_constructible_v<_Sentinel<true>>) /* strengthened */
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_take_while_const<_Vw, _Pr>
#else // ^^^ workaround / no workaround vvv
requires range<const _Vw> && indirect_unary_predicate<const _Pr, iterator_t<const _Vw>>
#endif // TRANSITION, LLVM-47414
{
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_VERIFY(_Pred, "cannot call end on a take_while_view with no predicate");
Expand Down Expand Up @@ -3562,12 +3536,6 @@ namespace ranges {
_EXPORT_STD inline constexpr _Drop_while_fn drop_while;
} // namespace views

#ifdef __clang__
template <class _Rng> // TRANSITION, LLVM-47414
concept _Can_const_join = forward_range<const _Rng> && is_reference_v<range_reference_t<const _Rng>>
&& input_range<range_reference_t<const _Rng>>;
#endif // ^^^ workaround ^^^

template <class _Ty>
_NODISCARD constexpr _Ty& _As_lvalue(_Ty&& _Val) noexcept {
return static_cast<_Ty&>(_Val);
Expand Down Expand Up @@ -3934,11 +3902,7 @@ namespace ranges {
}

_NODISCARD constexpr _Iterator<true> begin() const
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_join<_Vw>
#else // ^^^ workaround / no workaround vvv
requires forward_range<const _Vw> && is_reference_v<_InnerRng<true>> && input_range<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
return _Iterator<true>{*this, _RANGES begin(_Range)};
}
Expand All @@ -3953,11 +3917,7 @@ namespace ranges {
}

_NODISCARD constexpr auto end() const
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_join<_Vw>
#else // ^^^ workaround / no workaround vvv
requires forward_range<const _Vw> && is_reference_v<_InnerRng<true>> && input_range<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
if constexpr (forward_range<_InnerRng<true>> && common_range<const _Vw> && common_range<_InnerRng<true>>) {
return _Iterator<true>{*this, _RANGES end(_Range)};
Expand Down Expand Up @@ -3994,13 +3954,6 @@ namespace ranges {
&& common_reference_with<range_reference_t<_Rng>, range_reference_t<_Pat>>
&& common_reference_with<range_rvalue_reference_t<_Rng>, range_rvalue_reference_t<_Pat>>;

#ifdef __clang__
template <class _Rng, class _Pat> // TRANSITION, LLVM-47414
concept _Can_const_join_with =
forward_range<const _Rng> && forward_range<const _Pat> && is_reference_v<range_reference_t<const _Rng>>
&& input_range<range_reference_t<const _Rng>>;
#endif // ^^^ workaround ^^^

_EXPORT_STD template <input_range _Vw, forward_range _Pat>
requires view<_Vw> && input_range<range_reference_t<_Vw>> && view<_Pat>
&& _Compatible_joinable_ranges<range_reference_t<_Vw>, _Pat>
Expand Down Expand Up @@ -4450,12 +4403,8 @@ namespace ranges {
}

_NODISCARD constexpr auto begin() const
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_join_with<_Vw, _Pat>
#else // ^^^ workaround / no workaround vvv
requires forward_range<const _Vw> && forward_range<const _Pat> && is_reference_v<_InnerRng<true>>
&& input_range<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
return _Iterator<true>{*this, _RANGES begin(_Range)};
}
Expand All @@ -4472,12 +4421,8 @@ namespace ranges {
}

_NODISCARD constexpr auto end() const
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_join_with<_Vw, _Pat>
#else // ^^^ workaround / no workaround vvv
requires forward_range<const _Vw> && forward_range<const _Pat> && is_reference_v<_InnerRng<true>>
&& input_range<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
if constexpr (forward_range<_InnerRng<true>> && common_range<_Vw> && common_range<_InnerRng<true>>) {
return _Iterator<true>{*this, _RANGES end(_Range)};
Expand Down Expand Up @@ -8013,16 +7958,6 @@ namespace ranges {
return _Evaluate_equality_closure(index_sequence_for<_LHSTupleTypes...>{});
}

#ifdef __clang__
template <bool _IsConst, class... _ViewTypes> // TRANSITION, LLVM-47414
concept _Zip_iter_converts =
_IsConst && (convertible_to<iterator_t<_ViewTypes>, iterator_t<const _ViewTypes>> && ...);

template <bool _IsConst, class... _ViewTypes> // TRANSITION, LLVM-47414
concept _Zip_sent_converts =
_IsConst && (convertible_to<sentinel_t<_ViewTypes>, sentinel_t<const _ViewTypes>> && ...);
#endif // ^^^ workaround ^^^

template <class _Func, class... _Views>
concept _Zip_transform_constraints =
move_constructible<_Func> && is_object_v<_Func> && (sizeof...(_Views) > 0) && (input_range<_Views> && ...)
Expand Down Expand Up @@ -8074,13 +8009,8 @@ namespace ranges {

constexpr _Iterator(_Iterator<!_IsConst> _Rhs) noexcept(
(is_nothrow_convertible_v<iterator_t<_ViewTypes>, iterator_t<const _ViewTypes>> && ...)) // strengthened
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Zip_iter_converts<_IsConst, _ViewTypes...>
#else // ^^^ workaround / no workaround vvv
requires (_IsConst && (convertible_to<iterator_t<_ViewTypes>, iterator_t<const _ViewTypes>> && ...))
#endif // __clang__
: _Current(_STD move(_Rhs._Current)) {
}
: _Current(_STD move(_Rhs._Current)) {}

_NODISCARD constexpr auto operator*() const
noexcept((noexcept(*(_STD declval<iterator_t<_Maybe_const<_IsConst, _ViewTypes>>&>()))
Expand Down Expand Up @@ -8285,13 +8215,8 @@ namespace ranges {

constexpr _Sentinel(_Sentinel<!_IsConst> _Rhs) noexcept(
(is_nothrow_convertible_v<sentinel_t<_ViewTypes>, sentinel_t<const _ViewTypes>> && ...)) // strengthened
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Zip_sent_converts<_IsConst, _ViewTypes...>
#else // ^^^ workaround / no workaround vvv
requires (_IsConst && (convertible_to<sentinel_t<_ViewTypes>, sentinel_t<const _ViewTypes>> && ...))
#endif // __clang__
: _End(_STD move(_Rhs._End)) {
}
: _End(_STD move(_Rhs._End)) {}

template <bool _IteratorConst>
requires (sentinel_for<sentinel_t<_Maybe_const<_IsConst, _ViewTypes>>,
Expand Down
Loading

0 comments on commit 29fccab

Please sign in to comment.