I want to have a template function like this:
template <class T>
void CreateBlankPatch(typename T::Pointer patch, unsigned int sideLength)
{
CreateConstantPatch(patch, typename T::PixelType::Zero(), sideLength);
}
It works fine as long as Zero() is defined for the class T. However, with POD types, this is clearly not the case. So I want an unsigned char version of the template, I tried to do this:
template <>
void CreateBlankPatch<unsigned char>(typename T::Pointer patch, unsigned int sideLength)
{
CreateConstantPatch(patch, 0, sideLength);
}
but it complained that T is not defined. I tried this (even though every example I've seen has empty <> for specializations):
template <class T>
void CreateBlankPatch<unsigned char>(typename T::Pointer patch, unsigned int sideLength)
{
CreateConstantPatch(patch, 0, sideLength);
}
and I get
error: template-id ‘CreateBlankPatch<unsigned char>’ in declaration of primary template
Anyone know how to do this?
Thanks,
David