property functions

Paul Backus snarwin at gmail.com
Sun May 16 16:18:22 UTC 2021


On Sunday, 16 May 2021 at 15:47:55 UTC, Adam D. Ruppe wrote:
> On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote:
>> Is this warning still valid?
>
> The @property thing doesn't do much. All it does is change 
> typeof(a.prop) from function over to the return value of the 
> function. (Which actually makes it required for the range empty 
> and front things!)

It's not required:

     struct Example
     {
         int front() { return 42; }
         bool empty() { return false; }
         void popFront() {}
     }

     import std.range;
     static assert(isInputRange!Example);


More information about the Digitalmars-d-learn mailing list