DIP 1018--The Copy Constructor--Community Review Round 1
Dru at notreal.com
Sat Dec 22 23:26:47 UTC 2018
First I want to say that I hope it gets implemented
Semantic consistency demands it:
A a = b; //calls this(B) or this(ref B)
A a2 = a; //*should* call this(ref A)
I have a few points:
1) "ref" vs "ref const" dilemma
The user can overload different kinds of copy ctors,
but what is the *default* copy ctor ?
I think the default copy ctor should be "ref const"
- "ref const" is safer and fits most cases
- "ref" has priority over "ref const" so the user can simply
and his "ref" ctor will be used instead of the default
2) "Generating copy constructors"
Should the user care when a constructor is "generated" if
semantics are consistent ?
May just say there is *always* a default copy ctor that can be
overriden by the user.
The implementation of default ctor can change and use memcpy as
3) Not very related but maybe also needs a fix:
I noticed that init to rvalue of a different type is weird right
A a1 = b; //calls this(ref B)
A a2 = B(); //does not call this(ref B)
More information about the Digitalmars-d