
On Tue, Oct 25, 2011 at 3:54 PM, Allan Johns <allan.johns@drdstudios.com>wrote:
In my case I have several data types - tables, buffers, tuples, attributes etc. I need to be able to clone (ie deepcopy) any part of one of these hierarchical structures... there is no "entire structure", if you will.
I understand what's being said about memory ownership, but in this case I have full control of my problem domain, and such a generic deep copy library would be useful and save time - otherwise I'm just going to have to implement deep copy behaviour inside of all my classes anyway (which is actually what I have at the moment). This pattern has come up several times before in my work, so it isn't a one-off, and the motivation is not to deal with cyclic dependencies (although that should probably be dealt with).
Perhaps there should be a 'deep copy context' that you can create for your own code or share from other libraries, so for eg one library's idea of what "deep copying" an std::vector is, can differ from another library's. Would this address your concern over ambiguity of memory ownership?
Given that this behaviour is implemented as a standard module in another language (python) I'm surprised it's being dismissed so easily?
Allan
ps -- I'm not a python programmer, just wanted to make that clear! Well I do use it but... you know what I mean.
It would help *me* if you gave a more concrete example of why this is useful...I feel like you're speaking in generalities that I'm having trouble connecting with :/ And, if it helps me, it might help others. - Jeff