Feedback Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Sat Mar 20 08:06:59 UTC 2021
On 3/17/2021 11:14 PM, Elronnd wrote:
>> 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.
>
> I think the order should be undefined. Forcing the moves to happen in lexical
> order may inhibit some optimizations; and code which relies on the order of
> implicit moves is fragile anyway and shouldn't be encouraged. If the order is
> important for legitimate reasons, then those reasons should be made explicit in
> the code with an explicit move constructor.
The trouble with that is the user may inadvertently rely on the
implementation-defined order, and his code will break when using another
implementation.
The optimization advantage, if any, would be slight and not worth the risk.
More information about the Digitalmars-d
mailing list