DIP 1018--The Copy Constructor--Community Review Round 1

Dru dru at notreal.com
Wed Jan 9 08:18:58 UTC 2019


> Why would you need a default copy constructor? If there aren't 
> any copy constructors defined, the compiler will just blit the 
> fields. Generating


For the sake of consistency.
Imagine if the user explicitly calls or uses the address of the 
(generated) copy ctor,
then a struct change is made and the copy ctor is "no longer 
needed" because you can blit.
The user code that explicitly used the constructor is now broken.

> a single default copy constructor is not enough.

how about:

this(ref const T other);
immutable this(ref const T other);


More information about the Digitalmars-d mailing list