为什么 numeric_limits<T>::min 被编译器解释为函数指针?

why is numeric_limits<T>::min being interpreted as a function pointer by compiler?

我正在使用模板编写浮点比较函数:

template<class T>
    static bool AlmostEqual(T f1, T f2) 

我有这样的陈述:

T min_value = std::numeric_limits<T>::min();

出于某种原因,编译器将上面的 min 视为函数指针并发出错误:

   ../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

静态函数被定义为大程序的一部分。但是,当我将相同的函数放在一个独立的文件中并编译和使用它时,我没有看到任何错误。我阅读了其他帖子并尝试了这样的操作:

T min_value(std::numeric_limits<T>::min());

我仍然遇到同样的错误,而且还有一个错误:

../include/CommonFunctions.h:22:53: error: macro "min" requires 2 arguments, but only 1 given

在一个错误中,它能够将 min 正确解析为一个函数,而在另一个错误中,它被视为一个宏。我不确定,如何解决这个问题。任何指针将不胜感激?

对于包括 windows.h 在内的人,请将以下内容设为生效 headers:

#include windows headers ...

pragma push_macro("min")
pragma push_macro("max")
#undef min
#undef max

#include headers expecting std::min/std::max ...

...

pragma pop_macro("min")
pragma pop_macro("max")

在源文件中只有 #undef min 和 max。

#include windows headers ...

#undef min
#undef max

#include headers expecting std::min/std::max ...