inout after function

Adam D. Ruppe destructionator at gmail.com
Sun Nov 26 04:51:08 UTC 2017


On Sunday, 26 November 2017 at 01:35:01 UTC, Dave Jones wrote:
> So it makes it a const/immutable/mutable method depending on 
> whether the instance it is called on is const/immutable/mutable?

On the outside, yes.

> So
>
>>     @property ref inout(int) front() inout {
>>         return i++;
>>     }
>
> Would fail if you called it on an immutable instance of S.

That wouldn't compile in any case: on the inside of the function, 
inout == const (this is the only way the one function can be used 
for all three). The inout propagation is just seen at the call 
site.


More information about the Digitalmars-d-learn mailing list