[fpc-devel] Move operator
Jonas Maebe
jonas at freepascal.org
Sat Jul 13 14:21:41 CEST 2019
On 10/07/2019 22:36, Ryan Joseph wrote:
> So I've started using the record management operators in earnest and see a real need for another “Move” operator in order to prevent the constant unnecessary copies. If you look at the example in the bug report you’ll see where adding a Move operator will save you 2 copies and that it works as a companion to the Copy operator, meaning if you don’t declare Move then Copy will be called by default.
In which scenarios do you need such a custom "move" operator, rather
than simply allowing the compiler to just copy the data from one place
to the other without calling a destructor on the old instance?
I can only imagine this would be a problem if your managed record
constructor/destructor automatically register/unregister pointers to
these managed record instances in another datastructure, but is that
valid in any case?
Jonas
More information about the fpc-devel
mailing list