[Insight-users] Smart pointers casting

Antonin Perrot-Audet antonin07130 at gmail.com
Sun Aug 29 19:19:23 EDT 2010


  Hello,
I would like to store a (smart)pointer in a class. This smart pointer 
points to a filter (imagetoimagefilter for the example).
I am trying to store a smart pointer to an itk::ProcessObject and cast 
it prior to using it for setting the input of the filter for instance.
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.

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 ?

Antonin Perrot-Audet
Electrical Engineering&  Computer Sciences, INSA Lyon
M2 GEGP Signal&  Image Processing, INSA Lyon, UCBL, Centrale Lyon



More information about the Insight-users mailing list