[Insight-users] More flexible assignment for itk::SmartPointer - PLEASE IGNORE MY PREVIOUS POST!

Maarten Nieber hallomaarten at yahoo.com
Tue Nov 25 11:09:34 EST 2008


Hi,

I apologise, my previous post was incorrect, please ignore it.
Thanks,
Maarten





________________________________
From: Maarten Nieber <hallomaarten at yahoo.com>
To: insight-users at itk.org
Sent: Tuesday, November 25, 2008 5:04:53 PM
Subject: More flexible assignment for itk::SmartPointer


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/ce9e577e/attachment.htm>


More information about the Insight-users mailing list