[Insight-users] help on generic programming: template function in template class

Ryan Guan ryan.guan at yahoo.com
Wed Jun 15 00:06:58 EDT 2011


I don't have that much experience in generic programming, so I got lost easily 
when I was trying to do this:
I had a template class which has several functions to do filter, registration, 
write-out, etc. This is how one function looks like in .cxx:

(typedef itk::Image< TPixelType, TImageDimension >  ImageType;)

template <typename TPixelType, unsigned int TImageDimension> 
>typename MyClass <TPixelType,TImageDimension>::ImageType::Pointer 
> MyClass<TPixelType,TImageDimension>::
>MyFlipFilter(typename MyClass<TPixelType,TImageDimension>::ImageType::Pointer 
>InputImage)
>{
>  typedef itk::FlipImageFilter< ImageType > FlipFilterType;
>  ..
>  ..
>  return  FlipFilter->GetOutput();
>}

Now I want to template 'ImageType' in the function too, because I may want to 
flip the displacement vector field which has vector pixel, like
typedef typename itk::Image< VectorType, TImageDimension > 
 DeformationFieldType;

Obviously just replacing ImageType with  TempType and stacking 'template' 
keyword don't work. I am not confident that I can put all the 'template' 
'typename' kewords at the correct places, so I hope to get some suggestions from 
you generic experts on how to do this properly? And, am I doing the proper work 
of building the MyFlipFilter function?

Thanks for any response!

Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110614/ccfe6819/attachment.htm>


More information about the Insight-users mailing list