how does isInputRange(T) actually work?
Vlad Levenfeld via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 22 17:48:51 PDT 2015
On Wednesday, 22 April 2015 at 21:22:43 UTC, Meta wrote:
>> That makes sense. It seems to me that D has very... special
>> but effective syntax. I'm having a hard time remembering all
>> the keywords and expression forms (especially of IsExpression)
>> but it's definitely a vast improvement over C++'s half baked
>> pile of whatever. Thanks for the help, everyone.
>
> The `is` expression is complicated and has a bunch of different
> usage syntax, but it's like one of those little multitools.
> Complicated to figure out how to use, but extremely flexible
> and able to do a lot of cool things.
Yeah, the `is` expression is one of my favorite D features.
import std.container;
template Substitute (T, U) {
static if (is (T == F!V, alias F, V))
alias Substitute = F!U;
}
alias List = SList!int;
static assert (is (Substitute!(List, char) == SList!char));
It's the little things.
More information about the Digitalmars-d-learn
mailing list