Home » U++ Library support » U++ Core » Vector(const Vector& v, int)
Vector(const Vector& v, int) [message #46839] |
Fri, 26 August 2016 00:03  |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
Hello,
What is a reason to keep the deep copy constructor Vector(const Vector& v, int)?
It prevents automatic generation of default copy constructor for classes using Vector. Default move constructor can be autogenerated, but copy constructor has to be coded manually.
Am I missing something?
TIA
Regards,
Novo
|
|
|
|
Re: Vector(const Vector& v, int) [message #46847 is a reply to message #46841] |
Fri, 26 August 2016 23:47   |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Fri, 26 August 2016 11:13With C++11, the reason is to make 'clone' explicit.
(That said, maybe there could be a better way how to achieve this, maybe make copy-constructor explicit would work too, but addition int parameter is sort of legacy).
Thank you.
Explicit copy-constructor doesn't force to call "clone" for some reason.
Maybe, it makes sense to make pick/clone optional, and let compiler auto-generate default copy constructor? This legacy move semantics doesn't seem to have much sense when compiler already does good job moving temporary data for you. You still will be able to call "pick". Typing code which is not really necessary is very annoying ...
Thanks.
Regards,
Novo
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:51:32 CEST 2025
Total time taken to generate the page: 0.00444 seconds
|