__rvalue and Move Semantics first draft
Walter Bright
newshound2 at digitalmars.com
Sat Nov 9 23:01:52 UTC 2024
On 11/9/2024 9:37 AM, kinke wrote:
> Oh, there's at least one problem with the `this(T)` move-ctor signature - C++
> interop. C++ doesn't destroy the parameter, because it's an rvalue-ref. The
> proposed by-value signature in D however includes the destruction of the
> value-parameter as part of the move-construction. The same applies to
> move-assignment via `opAssign(T)`. So after calling a C++ move ctor/assignOp
> with an `__rvalue(x)` argument, the rvalue wasn't destructed, and its state is
> as the C++ callee left it. Automatically reset-blitting to `T.init` would be
> invalid in that case, as the moved-from lvalue might still have stuff to destruct.
We could disallow __rvalue arguments for call to C++ functions?
More information about the dip.development
mailing list