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

tsbockman thomas.bockman at gmail.com
Sun Mar 14 04:27:26 UTC 2021


On Saturday, 13 March 2021 at 19:47:35 UTC, 12345swordy wrote:
> How does the DIP interact with the current alias this system?
> If I alias this a struct variable with move schematics in 
> struct/class definition called A, does A have the move 
> schematics of the struct variable?

According to the DIP, if A does not define explicit custom move 
operators, it gets implicit default field-by-field move operators:

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

So, A's own move operators (whether explicit custom or implicit 
default) should hide any that it might otherwise pick up via 
alias this. The DIP should probably be updated to make this 
interaction with alias this explicit, though.


More information about the Digitalmars-d mailing list