[Insight-users] Smart pointers casting

Karthik Krishnan karthik.krishnan at kitware.com
Tue Aug 31 02:46:29 EDT 2010


On Mon, Aug 30, 2010 at 4:49 AM, Antonin Perrot-Audet <
antonin07130 at gmail.com> wrote:

>
> But I get an invalid cast error
>
>
> itk::ProcessObject::Pointer m_itkFilter;
> [...]
> typedef itk::ImageToImageFilter<InputImageType> itkFilterType;
> typedef typename itkFilterType::Pointer itkFilterTypePointer;
>
> static_cast<itkFilterTypePointer>(m_itkFilter);
>
> Is there a way to do it ? The problem is that my class mustn't be template.
> There is only one template function : to set the input of the filter.
>

itkFilterTypePointer pDerived = static_cast< itkFilterType
*>(m_itkFilter.GetPointer());


>
> Also I was wondering : would the smart pointer destroy itself (and the
> associated object) in the end of the function, even if it is stored as a
> member of the object ?
>

no, if the class has the smartpointer as a member, it shouldn't go out of
scope.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100831/a3ab09a0/attachment.htm>


More information about the Insight-users mailing list