#include <cstdint>
#include <ranges>
int main()
{
auto const il = {1, 2, 3, 4, 5, 6};
auto const n1 = std::int32_t{3};
auto const n2 = std::uint32_t{3};
auto const n3 = std::int64_t{3};
auto const n4 = std::uint64_t{3};
il | std::views::take(n1); // ok
il | std::views::take(n2); // ok
il | std::views::take(n3); // ok
il | std::views::take(n4); // error
}
See online demo
Why can't compile std::views::take(std::uint64_t{})
?
range | std::views::take(n)
is expression equivalent to std::ranges::take_view(range, n)
, which takes a ranges::range_difference_t<V>
.
Following the aliases through, gcc 11.1 doesn't want to consider unsigned long
as usable where a long
is wanted