[Insight-users] Automatically deducing SmartPointer function template parameter
David Doria
daviddoria at gmail.com
Sat Jan 7 16:59:49 EST 2012
I have a tons functions with this type of signature:
template <typename TImage>void MyFunction(TImage* image)
If I create an image like this:
typedef itk::Image<int, 2> ImageType;
ImageType::Pointer image = ImageType::New();
And pass it like this:MyFunction(image);
I get an 'undefined function' error.
It works if I explicitly specify the template
parameter:MyFunction<ImageType>(image);
It also works if I pass the raw pointer:MyFunction(image.GetPointer());
If I change the function parameter to:
template <typename TImage>
void MyFunctionSmartPointer(typename TImage::Pointer image)
again it works if I explicitly specify the template parameter:
MyFunctionSmartPointer<ImageType>(image);
but still doesn't work if I just pass the smart pointer:
MyFunctionSmartPointer(image);
and curiously also doesn't work with the raw pointer:
MyFunctionSmartPointer(image.GetPointer());
Is there anything that can be done to pass a smart pointer to a
function and have it automatically deduce the type?
Thanks,
David
More information about the Insight-users
mailing list