Open
Description
Describe the issue
Motivation
When using absl::Overload
with std::visit
, the syntax requires constructing an explicit Overload object:
std::visit(absl::Overload{
[](int) { ... },
[](std::string) { ... }
}, my_variant);
Adding a MatchVariant helper would simplify this to:
absl::MatchVariant(my_variant,
[](int) { ... },
[](std::string) { ... });
Proposed implementation
template <typename Variant, typename... T>
auto MatchVariant(const Variant& v, T... args) {
return std::visit(Overload{args...}, v);
}
Steps to reproduce the problem
N/A
What version of Abseil are you using?
Latest version
What operating system and version are you using?
Debian testing
What compiler and version are you using?
clang
What build system are you using?
Ninja
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels