c++ 1y/14:自动变量模板

C++1y/14: auto variable templates?

本文关键字:变量 1y c++      更新时间:2023-10-16

下面的c++ 1y/c++ 14程序是病态的吗?

template<class> constexpr auto X = 42;
int main()
{
        static_assert(X<int> == 42, "");
}

为什么/为什么不?

Clang trunk抱怨:

error: invalid operands to binary expression ('auto' and 'int')

这是clang中的一个bug,现在已经修复了:http://llvm.org/bugs/show_bug.cgi?id=19152