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.
You can use __is_identifier for this. Clang's supported it since r206069 (version 3.5), which may be good enough? (How old a Clang release can still parse libc++?)