来自https://en.cppreference.com/w/cpp/utility/variant/visit:
visit
的返回值是什么?我不明白“selected invocation of visitor”是什么意思?
示例代码:
// Don't understand what this means, can explain? It's a templated func with trailing return type but no body?
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
// Why would the visitor function use && instead of &?
std::visit([](auto&& arg){std::cout << arg;}, v);
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>
是一个推导指南。 - Patrick Fromberg