Another problem with decltype
- by There is nothing we can do
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;
}
Using VS2010.
Please see 3 comments in code above.