Copy Constructor DIP

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jul 12 13:29:16 UTC 2018


On 07/11/2018 05:55 AM, Nick Treleaven wrote:
> On Tuesday, 10 July 2018 at 10:47:04 UTC, RazvanN wrote:
>> [1] https://github.com/dlang/DIPs/pull/129
> 
> Thanks for making the DIP. I can't get this code to compile (my struct 
> has an `int i` field):
> 
> static foreach (i, ref field; src.tupleof)
>      this.tupleof[i] = field;
> 
> Error: constant value src.i cannot be ref
> 
> https://run.dlang.io/is/qeugC8
> 
> Removing `static` works. Otherwise I tried changing `ref` to `alias`:
> 
> Error: variable src cannot be read at compile time
> 
> But this shorter code seems to work fine:
> 
> this.tupleof = src.tupleof;

Odd. Timon, what would be the reason for that error? Razvan, can you 
please look into removing "static" for now. Thanks!


More information about the Digitalmars-d mailing list