Added a deepcopy mechanism#392
Conversation
|
Thank you very much! This solves my use case. Reading the PR I wondered why you added a clone instead of just a copy constructor? In your case you return by value. which means that the clone function is just a the same as a copy constructor but with a different name? Is there any reason not to just use the copy constructor, and define it in the cases where the default will create shallow copies? Or are the shallow copies intentional, and needed for some use case? As a C++ dev Im used to value based design and the rule of 5/3/0 etc. But I can understand if you have different needs, Im mostly just curious about the reasoning. |
I must admit there is not much thought.. Since I was not sure how deep I could test this, I just decided the worst case scenario was the best way to do it, and since I have two binders, including a Python one, I was worried it would conflict if I was just adding a new constructor... clone (or deepcopy) method was therefore my goto... But again, it probably would have work (except for the internal shared_ptr in one of the class. That said, if you have a better way to do it, feel free to PR, I am not specifically trained in C++, it is mostly self teached! :) |
This change is