how does isInputRange(T) actually work?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 21 14:20:23 PDT 2015


On 04/21/2015 12:06 PM, kevin wrote:
> enum bool isInputRange = is(typeof(
>      (inout int = 0)
>      {
>          R r = R.init;     // can define a range object
>          if (r.empty) {}   // can test for empty
>          r.popFront();     // can invoke popFront()
>          auto h = r.front; // can get the front of the range
>      }));
>
>
> ... is the current implementation in Phobos. But I can't seem to
> understand this syntax. What is (inout int = 0)? Why can a block follow it?
>
> My guess is that this is declaring some sort of function and testing if
> it is syntactically valid, but this is still strange to me.

I try to explain that syntax here:

 
http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.named%20template%20constraint

Ali



More information about the Digitalmars-d-learn mailing list