Advanced tree operations classes

Problem seems to be trivial, but there trees differs from I always use:
I don't add simple elements, but construct big trees from smaller trees. I am using shared_ptr<BaseType>. Elements have polymorphism and must be cloned, because I can add element twice and modify only one.
My problem is replacing element/subtree with subtree. I can't use a.replace(b) because a must changed, not only a data. I can't add to a subelements of b, because b is differs type than a. I can't call parenta.replace(a,b) because a can be root and is a number types and code will redundant and must be only for type A. I try elements with shared_ptr and second type - objects on stack A holds this one pointer and call A.replace(new) but this is not too good.
Topic archived. No new replies allowed.