
Lorenzo Bettini <bettini@dsi.unifi.it> writes:
David Abrahams wrote:
Can you deal with deallocation of the whole network at once? It often works to maintain the nodes (C objects) in a container like a deque and let them link to one another with raw pointers. Otherwise you may be in need of a real GC.
I solved the problem in a (probably) not too elegant way: when I know that I'm creating objects with mutual dependences say A and B I store weak pointers, and I store a shared pointer to A and B into a list. As long as the list survives the weak pointers are still valid. When I want to deallocate everything, all I have to do is to deallocate the list. This worked, and also valgrind says there are no leaks...
The smart pointers may not be buying you much of anything in that case. -- Dave Abrahams Boost Consulting www.boost-consulting.com