When D feels unfinished: union initialization and NRVO

kinke noone at nowhere.com
Thu Mar 19 13:34:11 UTC 2020


On Thursday, 19 March 2020 at 10:17:20 UTC, Mathias Lang wrote:
> If you turn the `version(none)` into `version(all)` you'll see:
> ```
> nrvo.d(54): Error: struct nrvo.Foo is not copyable because it 
> is annotated with @disable
> nrvo.d(57): Error: struct nrvo.Foo is not copyable because it 
> is annotated with @disable
> nrvo.d(60): Error: struct nrvo.Foo is not copyable because it 
> is annotated with @disable
> nrvo.d(63): Error: struct nrvo.Foo is not copyable because it 
> is annotated with @disable
> ```

Another simple workaround:

import core.lifetime : move;

...
case Good.Baguette:
     Foo f = { type_: type, f1: typeof(Foo.f1)("Hello World") };
     return move(f);
...



More information about the Digitalmars-d mailing list