C++11 SFINAE for expressions fails with Intel C++ 18.0 and Intel C++ 19.0 even though it succeds with vc++14.1 and vc++14.2. The code:
template<class> struct ignore { typedef void type; }; template<class T> T& object(); template<class T, class E = void> struct trait { static const int value = 0; }; template<class T> struct trait<T, typename ignore<decltype(&object<T>())>::type> { }; template<class T> struct result { static const int value = T::value; }; class type { void operator&() const { } }; int test() { return result<trait<type> >::value; } int main() { return test(); }
The error:
test_cxx11_sfinae_expression.cpp
test_cxx11_sfinae_expression.cpp(19): error: class "trait<type, void>" has no member "value"
static const int value = T::value;
^
detected during instantiation of class "result<T> [with T=trait<type, void>]" at line 28
The code also fails with earlier versions of Intel C++ on Windows but this is expected since it also fails with vc++14.0 on down. Since Intel C++ is compilng in C++14 mode by default, in order to emulate vc++ 14.1 on up, the code should compile correctly.
TCE Open Date:
Sunday, December 15, 2019 - 19:45