I was writing a floating point comparison function using templates:
template<class T>
static bool AlmostEqual(T f1, T f2)
I had a statement such as:
T min_value = std::numeric_limits<T>::min();
For some reason the compiler treats the min above as a function pointer and issues the error:
../include/CommonFunctions.h: In static member function ‘static bool CommonFunctions::AlmostEqual(T, T) [with T = double]’:
file.cpp:2200: instantiated from here
../include/CommonFunctions.h:22: error: cannot convert ‘double (*)()throw ()’ to ‘double’ in initialization
The static function is defined as part of a big program. But, when I put the same function in a standalone file and compile and use it, I see no error. I read other posts and tried something like this:
T min_value(std::numeric_limits<T>::min());
I still get the same error and also one more:
../include/CommonFunctions.h:22:53: error: macro "min" requires 2 arguments, but only 1 given
In one error, it is able to resolve the min as a function correctly and in another error it is being treated as a macro. I'm not sure, how to resolve this issue. Any pointers would be appreciated?