Move Constructor Syntax
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Fri Oct 11 17:58:19 UTC 2024
On Friday, October 11, 2024 4:17:07 AM MDT Salih Dincer via Digitalmars-d
wrote:
> Suppose everything goes well and we continue on our way with the
> best option. Will we be able to know by looking at a flag that
> the object has been moved before?
No. A move is supposed to take the object and move it to a new location
(which by default would just be a memcpy). Keeping track of whether that has
ever happened before would require storing additional information somewhere.
You could put a member in your type which got updated when the move
constructor was called so that you could count the number of moves - or
simply indicate that a move has occurred at some point - but the compiler
couldn't keep track of that information without explicitly storing it
somewhere separate from the object, and there really isn't any reason why
you would normally care about that information.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list