https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670
schlaffi at users dot sourceforge.net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schlaffi at users dot
sourceforge.
| |net
--- Comment #3 from schlaffi at users dot sourceforge.net ---
This still affects g++ 9.2.1.
clang fixed this between 6.0.0 and 7.0.0, icc 13 and msvc 19 also work.
This has nothing to do with class functions:
static void foo( int, int ) { }
template <typename... T>
void bar1( void ( * )( int, T... ) ) { }
template <typename... T>
void bar2( void ( * )( T..., int ) ) { }
int main() {
bar1<int>( foo );
bar2<int>( foo );
}
Because we have twice "int" in foo, the error message is slightly different:
arg_deduct.cc: In function ‘int main()’:
arg_deduct.cc:11:18: error: no matching function for call to ‘bar2<int>(void
(&)(int, int))’
11 | bar2<int>( foo );
| ^
arg_deduct.cc:7:6: note: candidate: ‘template<class ... T> void bar2(void (*)(T
..., int))’
7 | void bar2( void ( * )( T..., int ) ) { }
| ^~~~
arg_deduct.cc:7:6: note: template argument deduction/substitution failed:
arg_deduct.cc:11:18: note: candidate expects 1 argument, 2 provided
11 | bar2<int>( foo );
| ^
The analogous construction with classes works like charm:
template <typename...>
struct Foo {};
static Foo<int, int> foo;
template <typename... T, template<typename...> typename C>
void bar1( C<int, T...> ) {}
template <typename... T, template<typename...> typename C>
void bar2( C<T..., int> ) {}
int main() {
bar1<int>( foo );
bar2<int>( foo );
}