对于这个代码示例,两个编译器会产生不同的结果。
Clang 生成两种不同的类型。 G++ 对 fu
和 fi
使用相同的类型。
哪个符合标准?
#include <iostream>
template< auto IVAL>
struct foo {
decltype(IVAL) x = -IVAL;
};
int main()
{
foo<10u> fu;
foo<10> fi;
std::cout << fi.x << " " << fu.x << '\n';
return 0;
}
g++-7.3输出:
4294967286 4294967286
clang-6.0 输出:
-10 4294967286
最佳答案
关于c++ - 自动模板参数 : g++ 7. 3 vs clang++ 6.0 : Which compiler is correct?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48594693/