Skip to content

[libc++/clang] std::ranges::views::take does not work with | operator #55673

Closed as not planned
@mattreecebentley

Description

@mattreecebentley

The following code in C++20:

#include <vector>
#include <ranges>


int main()
{
	std::vector<int> i_vec({1, 2, 3});
	auto rng = i_vec | std::ranges::views::take(2);
	return 0;
}

Produces the following error in Clang 14.00:

<source>:8:19: error: invalid operands to binary expression ('std::vector<int>' and '_Partial<std::ranges::views::_Take, decay_t<int>>' (aka '_Partial<std::ranges::views::_Take, int>'))
        auto rng = i_vec | std::ranges::views::take(2);

Godbolt: https://godbolt.org/z/c35r4Pa1h

The code as far as I can tell, is valid and works in GCC11 and MSVC 2022.
Unsure whether this is a libc++ or clang bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsduplicateResolved as duplicate

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions