有了这个测试程序,我就有了问题:
#include <cmath>
constexpr auto val1 = 1.23f;
constexpr auto val2 = HUGE_VALF;
static_assert(val1 == val1, "OK");
static_assert(val2 == val2, "OK");
int main()
{
}
结果:
输出:
1> TestConstexpr.cpp(5): error C2144: syntax error : 'auto' should be preceded by ';'
1> TestConstexpr.cpp(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> TestConstexpr.cpp(6): error C2144: syntax error : 'auto' should be preceded by ';'
1> TestConstexpr.cpp(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> TestConstexpr.cpp(6): error C2086: 'int constexpr' : redefinition
1> TestConstexpr.cpp(5) : see declaration of 'constexpr'
1> TestConstexpr.cpp(8): error C2057: expected constant expression
1> TestConstexpr.cpp(9): error C2057: expected constant expression