From: Axter (boost_at_[hidden])
Date: 2005-08-17 06:05:32
----- Original Message -----
From: "Philippe Mori" <philippe_mori_at_[hidden]>
Sent: Tuesday, August 16, 2005 7:35 PM
Subject: Re: Propose adding Clone Smart Pointer (clone_ptr) to
>> 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
> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk