I have this template :
template <class SourceFormat, class DestFormat, void (*convert)(DestFormat, SourceFormat)>
static void _draw(...);
And these functions :
template <class Class1, class Class2>
inline static void convertNone(Class1& dest, Class2& source) {
dest = source;
};
inline static void convertARGB_GREY(unsigned __int32& dest, unsigned __int8& source) {
dest = source + (source << 8);
dest += (dest << 16);
};
I use the template in another function :
void Blitter::draw(...) {
if (...) {
_draw<unsigned __int32, unsigned __int32, &convertNone>(...);
} else {
_draw<unsigned __int32, unsigned __int8, &convertARGB_GREY>(...); // ERRORS go here!
}
}
I get these errors :
Error 1 error C2440: 'specialization' : cannot convert from 'void (__cdecl *)(unsigned int &,unsigned char &)' to 'void (__cdecl *const )(unsigned char,unsigned int)' d:\projects\fanlib\source\blitter.cpp 102
Error 2 error C2973: 'FANLib::Blitter::_draw' : invalid template argument 'void (__cdecl *)(unsigned int &,unsigned char &)' d:\projects\fanlib\source\blitter.cpp 102
I suppose it's rather obvious that I don't fully comprehend functions-as-parameters... :-(
Many thanks in advance