Boost logo

Boost :

Subject: Re: [boost] Interest in boost.deepcopy
From: David A. Greene (greened_at_[hidden])
Date: 2011-11-02 14:49:45

Dave Abrahams <dave_at_[hidden]> writes:

> on Mon Oct 24 2011, Allan Johns <> wrote:
>> Just gauging initial interest in a boost.deepcopy library
> <pet peeve alert>
> Sorry to slam this idea out of the gate, but the whole notion of a
> "deep copy" is broken and wrong (in my humble opinion). When you say
> you're going to "deep copy" an object it shows you don't understand
> the boundaries of that object's value. The object's value is copied
> by its copy constructor, and compared by its operator== (assuming it
> has one). If your "deep copy" extends beyond the boundaries of the
> value, there's no way of knowing how far it should extend.

Fascinating discussion. I'm curious about your statement here. Do you
object to "deep copy" as implemented in a copy constructor or the notion
of "deep copy" of some aggregate data structure in general?

For example, I have often needed to clone some branch of a tree data
structure where nodes contain pointers to other nodes. For me this is
in the context of a compiler and subtree cloning is a convenient way to
perform code duplication. In the past I have implemented a virtual
clone() member for each kind of tree node in order to get polymorphic
behavior. clone() clones child nodes and all that.

If your objection covers cases like the above, I am very interested in
alternative solutions.



Boost list run by bdawes at, gregod at, cpdaniel at, john at