overloaded inherited from each lambda separately, and each lambda has a call statement. Therefore, you create a structure that has all the call statements in one set of overloads. As long as they are not ambiguous, the correct one will be automatically selected.
You can imagine a variation template expand to
struct overloaded : // inherits from decltype([](auto arg) { std::cout << arg << ' '; }), decltype([](double arg) { std::cout << std::fixed << arg << ' '; }), decltype([](const std::string& arg) { std::cout << std::quoted(arg) << ' '; }) // has three operator()s { using decltype([](auto arg) { std::cout << arg << ' '; })::operator(); using decltype([](double arg) { std::cout << std::fixed << arg << ' '; })::operator(); using decltype([](const std::string& arg) { std::cout << std::quoted(arg) << ' '; })::operator(); };
Except for real code, this will not work, because lambdas with the same body will still have different types.
It creates type 1 overloaded with multiple inheritance per instance.
source share