Forgive me if this is obvious, but I couldn't find explicit documentation on this case—
Consider:
[](int a, const auto&... args, int b) {return b;}(1,0,0,0,4);
This produces the following error in c++20 with clang
:
./main.cpp:5:3: error: no matching function for call to object of type '(lambda at ./main.cpp:5:3)' [](int a, const auto&... args, int b) { return b;}(1,0,0,0,4); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./main.cpp:5:3: note: candidate function [with args:auto = <>] not viable: requires 2 arguments, but 5 were provided
Ok, I could sort of see why that wouldn't work. But I could also see why it would.
What is the exact reason this does not compile? Why is the compiler not able to infer the middle three arguments? Is this explicitly forbidden by the standard?