I am learning about ranges and as I learned about range adaptors, they only accept viewable_range
as the first argument according to cppreference RangeAdaptorObject.
But when I tested this code on Compiler Explorer:
auto val = std::views::drop(std::vector{1, 2, 3, 4, 5}, 2);
I found that for clang 16.0.0 and gcc 12.0 (both with -std=c++20
), this code does compile, while for any older version it does not.
I also tried:
auto val = std::views::transform(std::vector{1, 2, 3, 4, 5}, 2);
This does not compile for any versions of compilers.
So why is it allowed to passing non-viewable_range to some range adaptors in newer version of compiler?