If I use a template function with T where T = itk::Image<unsigned char>::Pointer, everything is fine:
#include <itkImage.h>
class Test
{
public:
template <class T>
void Add(T patch);
};
template <class T>
void Test::Add(T patch)
{
}
int main(int, char*[])
{
Test a;
itk::Image<unsigned char>::Pointer image;
a.Add(image);
return EXIT_SUCCESS;
}
However, if I use a template function with a parameter T::Pointer where T = itk::Image<unsigned char>, I get errors:
#include <itkImage.h>
class Test
{
public:
template <class T>
void Add(typename T::Pointer patch);
};
template <class T>
void Test::Add(typename T::Pointer patch)
{
}
int main(int, char*[])
{
Test a;
itk::Image<unsigned char>::Pointer image;
a.Add(image);
return EXIT_SUCCESS;
}
error: no matching function for call to ‘Test::Add(itk::SmartPointer<itk::Image<unsigned char, 2u> >&)’
Can someone explain why these are different, and how to fix the second one?
Thanks,
David