
9 Nov
2013
9 Nov
'13
1:37 p.m.
2013/11/9 Eric Niebler
I'm not sure what problem you're solving with 2-phase construction of ranges. Can you clarify?
The point is that your proposed approach would store state in the range object, say, "mutable T obj_;" in istream_range, and the setup is performed only at construction, which makes it infeasible for reentrance. If someone do this: auto&& rng = istream_range<int>(std::cin) | filtered(...); copy(rng, a); std::cin.clear(); copy(rng, b); // wrong result, internal 'next' not called This is a bit contrived, and I'm not sure if there would be more range/adaptor which have state... Maybe the idea of 2-phase construction is just an oversight, and it won't play with range-based for loop :/