template<class IntT, IntT low = IntT(), IntT high = IntT()>
struct X
{
static_assert(std::is_same<decltype(low),decltype(high)>::value,"Different types not allowed");//this should give error if types are different
decltype(low) a;
decltype(high) b;
X():a(decltype(a)()),b(decltype(b)())//WHY THIS DOES NOT COMPILE?
{
cout << typeid(a).name() << '\n';
cout << typeid(b).name() << '\n';
}
};
int _tmain(int argc, _TCHAR* argv[])
{
X<char,1,'a'> x;//this according to static_assert shouldn't compile but it does
return 0;
}
使用VS2010。
请参阅上面代码中的 3 条注释。