Boost logo

Boost Users :

From: Timothy Ritchey (tritchey_at_[hidden])
Date: 2004-10-26 08:09:46


Peter,
On Oct 22, 2004, at 11:03 AM, Peter Dimov wrote:
>
> Why do you need to pass a shared_ptr to the visitor?

That is a very good question. I had a couple of motivations: first, I
thought I read somewhere that it was generally a good idea to make
interfaces take shared_ptrs in order to help with issues of ownership.
Also, the visitor is being used to interpret a program tree, which
involves a mixture of singleton functors as well as normal program
constructs that are free to be destroyed once they are done. By taking
shared_ptrs, it greatly simplifies the management of nodes when
performing a reduction on the tree.

That being said, I suppose I could have taken the pointers, and then
just had local shared_ptrs in each function.

> You'll need to try to eliminate the multiple enable_shared_from_this
> bases. This can typically be done by following the "non-leaf classes
> should be abstract" advice. IOW:

Thanks for the advice. I was able to get it working once I made all
non-leaf nodes abstract, and did a little refactoring of the tree.

Thanks again for the help.

Cheers,
tim


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net