I’m getting a strange error. I have a function of the following signature:
template <typename DATA, DATA max>
static bool ConvertCbYCrYToRGB(const Characteristic space, const DATA *input, DATA *output, const int pixels) {
Which is later called like this:
case kByte:
return ConvertCbYCrYToRGB<U8, 0xFF>(space, (const U8 *)input, (U8 *)output, pixels);
case kWord:
return ConvertCbYCrYToRGB<U16, 0xFFFF>(space, (const U16 *)input, (U16 *)output, pixels);
case kInt:
return ConvertCbYCrYToRGB<U32, 0xFFFFFFFF>(space, (const U32 *)input, (U32 *)output, pixels);
case kFloat:
return ConvertCbYCrYToRGB<R32, FLT_MAX>(space, (const R32 *)input, (R32 *)output, pixels);
case kDouble:
return ConvertCbYCrYToRGB<R64, DBL_MAX>(space, (const R64 *)input, (R64 *)output, pixels);
The U* and R* are aliases for the unsigned integer and floating point types, respectively. What’s weird is that all the integer ones work perfectly, while the floating point ones fail with a somewhat enigmatic error:
DPXColorConverter.cpp:171: error: no matching function for call to ‘ConvertCbYCrYToRGB(const dpx::Characteristic&, const dpx::R32*, dpx::R32*, const int&)’
Any thoughts?
As aaa pointed out, you can’t use floating point numbers as template value parameters. But in this instance you don’t need to. Get rid of the second parameter entirely, and then in the definition of ConvertCbYCrYToRGB instead of using ‘max’ use
std::numeric_limits<DATA>::max(). Documentation on numeric_limits is here: http://www.cplusplus.com/reference/std/limits/numeric_limits/