我有以下代码:
template <typename, typename>
struct AAA{};
template<typename ...Args>
void f(AAA<Args...> *) {}
int main() {
f<int, int>(nullptr);
}
Run Code Online (Sandbox Code Playgroud)
此代码导致编译错误.使用g++ -std=c++1z错误编译时显示如下:
prog.cc: In function 'int main()':
prog.cc:8:24: error: no matching function for call to 'f<int, int>(std::nullptr_t)'
f<int, int>(nullptr);
^
prog.cc:5:6: note: candidate: template<class ... Args> void f(AAA<Args ...>*)
void f(AAA<Args...> *) {}
^
prog.cc:5:6: note: template argument deduction/substitution failed:
prog.cc:8:24: note: mismatched types 'AAA<Args ...>*' and 'std::nullptr_t'
f<int, int>(nullptr);
Run Code Online (Sandbox Code Playgroud)
使用clang++ -std=c++1z错误是:
prog.cc:8:5: error: no matching function for …Run Code Online (Sandbox Code Playgroud)