Property access to a struct that contains struct

Guenter via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 26 04:05:53 PST 2017


On Sunday, 26 February 2017 at 11:18:12 UTC, Mike Parker wrote:
> On Sunday, 26 February 2017 at 11:05:42 UTC, Guenter wrote:
>> Hi,
>>
>> i do not understand where I am wrong in this code. I seems 
>> there is a missing constructor, but i have no idea where.
>
>>
>>   @property A_t  ext() { return fext; }
>
> Structs in D are value types, so you're returning a copy of 
> fext here and that's what's getting updated with the new value. 
> Try this:
>
> ref A_T ext() { return fext; }

Thank you.
Guenter


More information about the Digitalmars-d mailing list