Could I use an std functions in a template functions?
I have add and wrote
#pragma region BlendFunctions
template <class T>
T BlendLightenf(T x, T y)
{
return std::max(x, y); //errors here
}
template <class T>
T BlendDarkenf(T x, T y)
{
return std::min(x, y); //errors here
}
And get
error C2589: '(' : illegal token on right side of '::'
and
error C2059: syntax error : '::'
right in the one string (x and y are usually float).
My defines:
#ifdef MAGICLIB_EXPORTS
#define CPPWIN32DLL_API __declspec(dllexport)
#else
#define CPPWIN32DLL_API __declspec(dllimport)
#endif
#include <stdio.h>
#include <string>
#include <algorithm>
Check that
maxisn’t defined by somebody else.Sometimes you include a file that defines
maxas something else (most likely(a > b ? a : b)or something like that).If you have one of those files included the preprocessor will break
std::maxby replacing max with its definition (something like thisstd::(a > b ? a : b)) and you get a strange error.You can add
#undef maxafter the offending header and you’ll be ok.