Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1

Arafel er.krali at gmail.com
Thu Mar 11 09:15:10 UTC 2021


On 11/3/21 10:01, Walter Bright wrote:
> On 3/11/2021 12:42 AM, Walter Bright wrote:
>> Constructing from an rvalue essentially is move construction.
> 
> I forgot to mention that the new semantics only apply to EMO objects, 
> which require both a move constructor and a move assignment operator. 
> The move constructor is new syntax. Therefore, it shouldn't break 
> existing code.

But we also read in the DIP, as it has already been mentioned:

> If a Move Constructor is not defined for a struct that has a Move Assignment Operator, a default Move Constructor is defined and implemented as a move for each of its fields, in lexical order.

It's not clear if a struct would be considered an EMO if either the Move 
Assignment Operator or the Move Constructor are defined by default.

If that's the case, any struct with an identity assignment operator 
would be silently "upgraded" to EMO, thus potentially breaking existing 
code: the original identity assignment might even throw, which according 
to the DIP will no longer be allowed.


More information about the Digitalmars-d mailing list