Today I was very surprised to find that Intel icpc (version 14.0.2 using std=c++0x ) could not compile the following snippet.
#include <type_traits> namespace traits_tests { template<typename> struct sfinae_true : std::true_type {}; template<typename T> static auto value_type(int) -> sfinae_true<typename T::value_type>; template<typename T> static auto value_type(void*) -> std::false_type; } template<typename C> struct has_value_type : decltype(traits_tests::value_type<C>(0)) {};
complains about the last line:
inc/traits.h(258): error: expected an identifier : decltype(traits_tests::value_type<C>(0)) {}; ^
The code works fine with clang and gcc .
I really do not like the complete rewrite to make it work with erroneous compilers (why are commercial compilers erroneous?).
- Is there an easier way than a completely different SFINAE template to make it work with
icc ?
EDIT : Yes, I know icc supporting decltype since some time. But in the specific context above, icc does not support it. Also note that using std=c++11 instead of std=c++0x does not matter.
source share