Propose adding Clone Smart Pointer (clone_ptr) to the boost library

I'm proposing to add the clone_ptr class to the boost library. I've developed a clone_ptr class that performs a clone of an abstract pointer without the need for a clone method. The clone_ptr is well suited for automatic deep copy of abstract pointers, and for use with STL containers. In addition to being able to perform clone operations, it also have operators that performs comparison on the object being pointed to, instead of the pointer address. This allows for correct sorting and comparison of clone_ptr's in an STL container. See following link for more info: http://code.axter.com/clone_ptr_introduction.htm Also check out the boost vault (clone_ptr_Introduction.zip )

I've developed a clone_ptr class that performs a clone of an abstract pointer without the need for a clone method.
How can you correctly do a clone when an interface does not have a clone method and you don't know the concrete type ? Also, what do you provide for class that have a clone method that is named differently (Clone is another often used function name at least in Active X (COM) programming)
See following link for more info: http://code.axter.com/clone_ptr_introduction.htm
Well, some functions are not exception safe or does not follows accepted rules like the one in (More) Exceptional C++ books. In particular, it is generally not safe to destroy an object and construct another one. What will happen if the object cannot be constructed and the original object is already destroyed. Will you have a clone_ptr that reference an invalid object. Philippe

----- Original Message ----- From: "Philippe Mori" <philippe_mori@hotmail.com> Newsgroups: gmane.comp.lib.boost.devel Sent: Tuesday, August 16, 2005 7:35 PM Subject: Re: Propose adding Clone Smart Pointer (clone_ptr) to theboostlibrary
I've developed a clone_ptr class that performs a clone of an abstract pointer without the need for a clone method.
How can you correctly do a clone when an interface does not have a clone method and you don't know the concrete type ?
The clone_ptr constructor is a template method, so it's able to store the type for later usage. As long as you pass in the pointer via the type you want clone on the constructor, the clone_ptr can easily determine the concrete type. Probably a more accurate name for this smart pointer would be clone_type_ptr, because it clones the type it recieves in the constructor. So the clone_ptr class template determines the pointer type, and the clone_ptr constructor template method determines the clone type. That's how the clone_ptr is able to clone the correct type, even though it's using an abstract type.
Also, what do you provide for class that have a clone method that is named differently (Clone is another often used function name at least in Active X (COM) programming)
IMHO, generic code should not be trying to deail with such specifc situations.
participants (2)
-
Axter
-
Philippe Mori