I ran into a problem with the following code, which compiles fine with gcc and clang, but fails with icc 18.0.1:
struct S { template< typename... Ts > auto access( ) -> int { return 1; } template< typename... Ts > auto operator()( Ts&&... ) -> decltype( access< Ts... >() ) { return access< Ts... >(); } }; struct A {}; struct B {}; int main() { S s; s( A(), B() ); }
Based on the types A and B the operator() of s shall call the access method of s. In my real world example the return value of access depends on the given template arguments, so I am using decltype to figure it out. However this does not work although it should or does the standard state something different and gcc and clang are just more friendly?
The error from the Intel compiler is:
test.cpp(24): error: no instance of function template "S::operator()" matches the argument list argument types are: (A, B) object type is: S s( A(), B() ); ^ test.cpp(11): note: this candidate was rejected because at least one template argument could not be deduced auto operator()( Ts&&... ) ^ compilation aborted for test.cpp (code 2)
Best regards,
Alexander Matthes