On Thursday, 14 March 2013 at 23:52:59 UTC, Nick Sabalausky wrote:
On Thu, 14 Mar 2013 17:54:52 -0400
Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:
it's not like we claim to support input ranges and
then call .save against them.
Although this is getting OT, we do kind of do that in a way:
It's very common for a range to be a struct rather than a
class. In
fact, std.range/algorithm has generally been considered to work
better with struct ranges with class ranges being a secondary
thought.
And yet, due the the nature of structs, all it takes to
effectively
".save" an InputRange (or at least attempt to) is this:
struct MyInputRange {...}
void foo(R)(R r) if(isInputRange!R) {
auto s = r;
}
...
foo(MyInputRange());
That implicitly does the equivalent of ".save" on a mere
InputRange
*twice*. The result, of course, is completely dependent on the
input
range in question.
Passing range by value is completely undefined, which is IMO a
big weak spot of ranges.