Both clang and GCC provide C++11 decltype semantics as decltype in c++03 mode. We should use this instead of typeof__ when availble.
GCC added decltype in 4.6.0, and AFAIK clang provided decltype ever since 3.3. Unfortunately __has_builtin(__decltype) doesn't work for clang so we need to check the compiler version instead.
I'm not really pleased with the idea of switching off the clang version. This kind of stuff grows over time.
If there is a better test, I'd rather use that.
If not, well...