dip1000, perhaps annotate with return, and vibe-d

aliak something at something.com
Thu Jul 25 18:34:08 UTC 2019


On Wednesday, 24 July 2019 at 16:23:48 UTC, Paul Backus wrote:
> On Wednesday, 24 July 2019 at 12:54:51 UTC, aliak wrote:
>> [...]
>
> It should go on the constructor's parameter; i.e.,
>
> this(auto return ref T value) { /* ... */ }
>
> Under the hood, a constructor actually returns the constructed 
> value by reference, so the actual signature of the above 
> constructor seen by the lifetime checker is:
>
> ref Optional!T __ctor(auto return ref T value)
>
> You can see this for yourself with something like `pragma(msg, 
> typeof(Optional!T.__ctor))`.

Thanks! The under the hood stuff was good to know!

I was putting it in the right place but it seems to still have 
been complaining. Ah well. I guess an auto ref on a constructor 
doesn't really make sense anyway.


More information about the Digitalmars-d-learn mailing list