template<class... Ts>
overloaded struct
Overloading trick to make functions take multiple overloaded lambdas.
Contents
- Usage:
-
Reference
Overloading trick for function that take lambdas where the parameter types can be different.
This is easier than writing
if constexpr (std::is_same_v<decltype(param), T>) { ... }
inside the lambda.
Usage:
std::visit( overloaded{ [](int i) { std::cout << "This is an int " << i << "\n"; }, [](std::string s) { std::cout << "This is a string " << s << "\n"; }, }, some_variant );
Source: https:/