User-Defined Deduction Guides in C++20
问题 I'm working with std::variant and std::visit using the "overload" pattern that looks like this: #include <iostream> #include <variant> template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; }; template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>; int main(void) { std::variant<int, float> var; auto fs = overloaded { [](int var) {std::cout << "var is int" << std::endl;}, [](float var) {std::cout << "var is float" << std::endl;} }; var = 0; std::visit(fs, var); var =