[Issue 19871] Copy constructor rejects valid code if default construction is disabled
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 14 16:08:38 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19871
--- Comment #4 from Atila Neves <atila.neves at gmail.com> ---
I disagree wholeheartedly that it should be the correct behaviour. I'm pasting
the same comment again here so it doesn't get lost.
I missed this discussion originally. The reason one one wants to have:
```d
struct Foo {
this(ref Foo);
this(Foo);
}
```
is simple: C++ interop. I made it so that the dpp translations actually enabled
D code to call a C++ move constructor by overloading on this.
More importantly, D should be able to do what C++ does without needing rvalue
references. So the equivalent of this should be possible:
-----------------------
struct Foo {
Foo(const Foo& foo); // copy ctor
Foo(Foo&& foo); // move ctor
};
-----------------------
As you can imagine, any and all types that have been updated post C++11 that
had copy constructors now have move constructors. Which I'd declare in D how,
exactly?
--
More information about the Digitalmars-d-bugs
mailing list