Suppose I have a tree data structure implemented with node class:
class Node
{
Node * parent;
std::vector<Node*> children;
int data_1;
std::string data_2;
double data_3;
...
float data_n;
};
To do a deep copy, is there any way to get around writing all of the boilerplate copying for the non-pointer properties? All of the
that.data_1 = this->data_1;
that.data_2 = this->data_2;
...
that.data_n = this->data_n;
I know in advance that the number of pointer properties is small and will not change. However, the non-pointer properties is larger and fluctuates as I develop my program. Thus, I'd rather avoid needing to remember to add this boilerplate code every time I add a new property.
(I'm willing to use C++11 and less enthusiastically boost)