|
Boost : |
From: Maik Beckmann (beckmann.maik_at_[hidden])
Date: 2008-05-18 19:36:08
Am Sonntag 18 Mai 2008 19:28:42 schrieb Giovanni Piero Deretta:
> On Sun, May 18, 2008 at 3:52 PM, Maik Beckmann
> I'm not a guru, but Instead of a vector<shared_ptrs<T> >, I'have used
> a shared_ptr <vector<T> > to implement recursive data structures. A
> clone pointer would work even better.
Giovanni, very nice!
At the c.l.c.m Jan posted another solution ()
<code>
struct tree_node
{
std::vector<tree_node> & children;
tree_node() :
children(*new std::vector<tree_node>)
{ }
tree_node(const tree_node & n) :
children(*new std::vector<tree_node> (n.children))
{ }
tree_node & operator =(tree_node n)
{
this->swap(n);
return *this;
}
~tree_node()
{ delete &this->children; }
void swap(tree_node & n)
{ this->children.swap(n.children); }
};
</code>
which doesn't involve boost.
Both use the fact
new std::vector<incomplete_type>
solves the problem.
Thank you very much,
-- Maik
PS: boost.poperty_tree should be fixed
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk