Thread overview
[Issue 19872] Copy constructor: Order of declaration yields different results with rvalue constructor
May 14, 2019
Atila Neves
May 14, 2019
RazvanN
May 14, 2019
RazvanN
May 14, 2019
Atila Neves
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19872

Atila Neves <atila.neves@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, C++,
                   |                            |rejects-valid, Vision

--
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19872

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
See discussion here: https://github.com/dlang/dmd/pull/8688#discussion_r248601249

The patch for 19871 will solve this bug too.

--
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19872

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
Closing as duplicate of 19871.

*** This issue has been marked as a duplicate of issue 19871 ***

--
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19872

--- Comment #3 from Atila Neves <atila.neves@gmail.com> ---
I added a comment in the discussion but will add it here as well:

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, so...

--