inout functions

Timon Gehr timon.gehr at gmx.ch
Thu Aug 23 15:42:23 PDT 2012


On 08/24/2012 12:14 AM, Piotr Szturmaj wrote:
> Hi,
>
> I found this code of std.range.iota's Result struct:
>
>          @property inout(Value) front() inout { assert(!empty); return
> current; }
>
> What's the purpose of inout on parameterless functions?

It is a method of a struct, therefore it is not parameterless, but has
a hidden parameter. 'inout' qualifies the implicit 'this' reference.
Inside the method body, typeof(this) is inout(Result).



More information about the Digitalmars-d-learn mailing list