I'm exploring the experimental ranges library implementation in gcc. When combining an infinite iota range with a filter view, I got a surprising compilation error (live example with GCC 9.0 HEAD 201812):
#include <iostream>
#include <vector>
#include <experimental/ranges/range>
int main()
{
using namespace std::experimental::ranges;
auto odds = view::filter([](int x){ return x%2 != 0; });
// auto v = std::vector{0,1,2,3,4,5};
// auto x = v | odds; // (1) ok
// auto x = view::iota(0,6) | odds; // (2) ok
// auto x = view::iota(0) | view::take(6); // (3) ok
auto x = view::iota(0) | view::take(6) | odds; // (4) error: sentinel?
for (auto e : x) std::cout << e << ' ';
}
What is wrong here?