C++ guys hate static_if?

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Thu Mar 14 16:52:52 PDT 2013


On Thu, 14 Mar 2013 17:54:52 -0400
Andrei Alexandrescu <SeeWebsiteForEmail at 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.



More information about the Digitalmars-d mailing list