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 = 0.0f;
std::visit(fs, var);
}
On cppreference, there's an example that says:
// explicit deduction guide (not needed as of C++20)
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
Why is this deduction guide no longer needed in C++20? Removing the type deduction guide causes the compile to fail on all current compilers, but no one fully supports C++20 right now so that doesn't mean anything. Can anyone point me to the part of the spec that discusses this?