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

Walter Bright newshound2 at digitalmars.com
Thu Mar 11 08:36:18 UTC 2021


On 3/10/2021 8:17 PM, tsbockman wrote:
> On Thursday, 11 March 2021 at 03:33:31 UTC, Walter Bright wrote:
>> On 3/10/2021 5:27 PM, tsbockman wrote:
>>> Yeah, studying the DIP I can't figure out what problem the move `opAssign` is 
>>> supposed to solve that the constructor doesn't:
>>> https://forum.dlang.org/post/kzgybicwqwlfyiiefucc@forum.dlang.org
>>
>> The thing about "destroy after move" is to deal with the case of both the 
>> source and the destination referring to the same object. The concern is that 
>> destroying the destination's original contents first will destroy them for the 
>> source before it gets moved in.
> 
> Wouldn't it make more sense to just skip the move operation entirely when the 
> source and destination are the same? Or are there circumstances in which that 
> cannot be determined, even at runtime?

The idea is that the move assignment operation takes care of this, and makes it 
"as if" the move was done, then the destruction.


More information about the Digitalmars-d mailing list