how to define my own traits

XavierAP via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 26 16:25:49 PDT 2017


I've looked into Phobos to emulate it when defining my own trait 
template, and when I see this:

module std.range.primitives;
// ...
template isInputRange(R)
{
     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
     }));

I wonder, why that unused parameter (inout int = 0)?
In my project () { /* ... */ } works the same for a custom trait.


More information about the Digitalmars-d-learn mailing list