Re: [boost] Propose adding Clone Smart Pointer (clone_ptr) to the boost library

----Original Message---- From: Thorsten Ottosen [mailto:nesotto@cs.aau.dk] Sent: 17 August 2005 17:19 To: boost@lists.boost.org Subject: Re: [boost] Propose adding Clone Smart Pointer (clone_ptr) to the boost library
"Martin Bonner" <martin.bonner@pitechnology.com> wrote in message
B) Under what circumstances is a std::container<clone_ptr<T> > better than a boost::ptr_container<T>?
I won't discuss if it's better, Perhaps "better" is too loaded a word. What I meant is that both allow a user to implement a container of heterogeneous objects. The documentation needs to explain when the user should choose one over the other (they must offer different trade-offs).
I was about to say "Just as the documentation compares and constrasts boost::any and boost::variant." However it turns out that it doesn't! It would be useful if it did.
but its certainly very different in thefollowing sense:
- ptr_container<T> discourages cloning of T objects and doesn't require it - vector<clone_ptr<T>> requires cloning of T objects (and hence encourages it)
If T is an OO-type with virtual functions, I find that identity often matters (performance and logical-wise) and hence that excessive cloning is best avoided. I agree. I think that clone_ptr is designed for a rather small niche, and I can't see myself ever needing it ... but that doesn't mean it couldn't be useful to somebody.
-- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 441434

Martin Bonner <martin.bonner@pitechnology.com> writes:
I agree. I think that clone_ptr is designed for a rather small niche, and I can't see myself ever needing it ... but that doesn't mean it couldn't be useful to somebody.
The general idea of a clone_ptr fills a very important niche, where the compiler firewall idiom is used to limit header dependencies for copy constructible objects. Apparently that's very common -- but I have never needed it ;-) -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Martin Bonner