我使用以下代码获得了最新版本的clang和gcc的错误:
int main() {
auto lambda = [] (auto = [] {}) {};
lambda();
}
Run Code Online (Sandbox Code Playgroud)
Clang给出错误:
prog.cc: In function 'int main()':
prog.cc:3:12: error: no match for call to '(main()::<lambda(auto:1)>) ()'
lambda();
^
prog.cc:2:35: note: candidate: template<class auto:1> main()::<lambda(auto:1)>
auto lambda = [] (auto = [] {}) {};
^
prog.cc:2:35: note: template argument deduction/substitution failed:
prog.cc:3:12: note: couldn't deduce template parameter 'auto:1'
lambda();
^
Run Code Online (Sandbox Code Playgroud)
为什么这会失败?