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

----Original Message---- From: Axter [mailto:boost@axter.com] Sent: 17 August 2005 01:54 To: boost@lists.boost.org Subject: Re: [boost] Propose adding Clone Smart Pointer (clone_ptr) to the boost library
The documents state that the clone_ptr class is based on strict pointer ownership logic. I am not familiar with that term, so it didn't help.
The above code is not using strict ownership logic, and instead the object is created using a dumb pointer. But your example code has this problem.
I also think you're right in that I should add more to the documentation Absolutely.
I am sure that this code satisfied a real need that you had. What is not at all clear is whether that need is widespread enough to justify including the clone_ptr in boost. What is needed is some clear documentation including: - an explanation of what problems the class solves ("motivating examples"). Note this doesn't need to be very detailed as too why the problem exists at this point. I imagine most people on this list understand concepts like "slicing". - An overview of the class usage (including the restrictions on how the class may be used) - A description of the specification of the class and its members, including the concepts that the template parameters must model. (Don't worry too much about getting the English right. If the library does go into boost, plenty of people here can help with that later.) Finally you might like to consider the following: A) I can see how something like this might be useful to allow a copyable class which owns an object of a polymorphic type. However, under what circumstances is this better than providing a clone() member in the polymorphic type? B) Under what circumstances is a std::container<clone_ptr<T> > better than a boost::ptr_container<T>? -- 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> 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 its better, 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. -Thorsten
participants (2)
-
Martin Bonner
-
Thorsten Ottosen