I'm getting unexpected results from all compilers on which I tried the following (GCC 4.7.2, GCC 4.8.0 beta, ICC 13.0.1, Clang 3.2, VC10):
#include <type_traits>
int main()
{
// This will fire
static_assert(
std::is_same<decltype("Hello"), char const[6]>::value,
"Error!"
);
}
I would have expected the compile-time assertion above not to fire, but it does. After all, this one does not (as expected):
#include <type_traits>
int main()
{
char const hello[6] = "Hello";
// This will not fire
static_assert(
std::is_same<decltype(hello), char const[6]>::value,
"Error!"
);
}
So what is the result of decltype("Hello")
according to the C++11 Standard (references are highly appreciated)? What should I compare it to so that the compile-time assertion above doesn't fire?