Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied LLVM-47414 workaround to std::ranges::join_view #2352

Merged
merged 6 commits into from Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions stl/inc/ranges
Expand Up @@ -3042,6 +3042,9 @@ namespace ranges {
/* [[no_unique_address]] */ _Non_propagating_cache<_Cache_wrapper, false> _Inner{};
};

template <class _Rng> // TRANSITION, LLVM-47414
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
concept _Can_const_join = input_range<const _Rng> && is_reference_v<range_reference_t<const _Rng>>;

// clang-format off
template <class _Vw>
requires is_reference_v<range_reference_t<_Vw>>
Expand Down Expand Up @@ -3340,7 +3343,12 @@ namespace ranges {

// clang-format off
_NODISCARD constexpr _Iterator<true> begin() const
requires input_range<const _Vw> && is_reference_v<_InnerRng<true>> {
#ifdef __clang__ // TRANSITION, LLVM-47414
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
requires _Can_const_join<_Vw>
#else // ^^^ workaround / no workaround vvv
requires input_range<const _Vw> && is_reference_v<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
// clang-format on
return _Iterator<true>{*this, _RANGES begin(_Range)};
}
Expand All @@ -3356,7 +3364,12 @@ namespace ranges {

// clang-format off
_NODISCARD constexpr auto end() const
requires input_range<const _Vw> && is_reference_v<_InnerRng<true>> {
#ifdef __clang__ // TRANSITION, LLVM-47414
requires _Can_const_join<_Vw>
#else // ^^^ workaround / no workaround vvv
requires input_range<const _Vw> && is_reference_v<_InnerRng<true>>
#endif // TRANSITION, LLVM-47414
{
if constexpr (forward_range<const _Vw> && forward_range<_InnerRng<true>>
&& common_range<const _Vw> && common_range<_InnerRng<true>>) {
// clang-format on
Expand Down
8 changes: 8 additions & 0 deletions tests/std/tests/P0896R4_views_join/test.cpp
Expand Up @@ -561,6 +561,14 @@ int main() {
static_assert(ranges::distance(views::iota(0, 2) | views::transform(ToArrayOfImmovable) | views::join) == 6);
}

{ // Joining a non-const view without const qualified begin and end methods
vector<vector<int>> nested_vectors = {{0}, {1, 2, 3}, {99}, {4, 5, 6, 7}, {}, {8, 9, 10}};
auto RemoveSmallVectors = [](const vector<int>& inner_vector) { return inner_vector.size() > 2; };
auto filtered_and_joined = nested_vectors | views::filter(RemoveSmallVectors) | views::join;
static constexpr int result[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
assert(ranges::equal(filtered_and_joined, result));
}

STATIC_ASSERT(instantiation_test());
instantiation_test();
}