[Insight-users] More flexible assignment for itk::SmartPointer
Maarten Nieber
hallomaarten at yahoo.com
Tue Nov 25 11:04:53 EST 2008
Hi,
I hope I am not restarting any old discussions, but I would like to be able to assign an itk::SmartPointer to another pointer that has a compatible type, for example:
itk::Image<3, double>::Pointer image = itk::Image<3, double>::New();
itk::ImageBase<3>::Pointer p = image;
Note that boost::shared_ptr works like this.
The behaviour could be achieved using a templated copy constructor for itk::SmartPointer:
template< class TObjectType2 >
SmartPointer(const SmartPointer<TObjectType2>& rhs)
{
// do a dynamic_cast here, and assign the result to rhs
}
Would this be a good idea?
Best regards,
Maarten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081125/701967d9/attachment.htm>
More information about the Insight-users
mailing list