Return type relying on template-dependant value?

Hello everyone !

I try to create my own itk filter based on the ImageToImageFilter. Following the guideline, we could access to the run-time image dimension with TInputImage::ImageDimension or with the help of the itkSetStaticConstMacro for the members variables or into members functions.

But I want to have functions with return type based on this ImageDimension, for example :
itk::Image<float, TInputImage::ImageDimension>::Pointer CreateDeepCopy(itk::Image<float, TInputImage::ImageDimension>::Pointer InputImage)
{
// … processing
// return pointer
}

This does not compile, as ImageDimension is not recognized properly into the return type :
" error C2146: syntax error : missing ‘;’ before identifier ‘CreateDeepCopy’ "

How can I correct that ?

Tim

If I remember correctly, it is a limitation of type inference system in the compilers. The workaround is to declare the method bypassing the Pointer typedef. Something like this:

itk::SmartPointer<itk::Image<float, TInputImage::ImageDimension> > CreateDeepCopy(itk::SmartPointer<itk::Image<float, TInputImage::ImageDimension> > InputImage)
{
// … processing
// return pointer
}

Thanks Dženan, it works perfectly now !