[Issue 20424] A constructor with a value argument of the same type as being constructed should be an error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 17 04:11:37 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20424
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #5 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Walter Bright from comment #2)
> An object with a copy constructor cannot be blitted into place. (Such is not
> allowed in C++, either, and such constructors are rejected by the compiler.)
>
> There is no advantage to doing it anyway over passing by ref.
Yes there is. You may want to construct from an rvalue, therefore you cannot
use a copy constructor since rvalue references are not yet implemented in the
language (there is a switch but it is only half implemented). `this(S)` does
exactly that. Of course, it is illegal to have both this(S) and this(ref S).
We discussed this extensively in the DIP.
--
More information about the Digitalmars-d-bugs
mailing list