absl::Overload is a functor that provides overloads based on the functors with which it is created. This can, for example, be used to locally define an anonymous visitor type for std::visit inside a function using lambdas.
Synopsis
Declared in <absl/functional/overload.h>
template<typename... T>
struct Overload final
: T...
Description
Before using this function, consider whether named function overloads would be a better design.
Example:
std::variant<std::string, int32_t, int64_t> v(int32_t{1}); const size_t result = std::visit(absl::Overload{ []std::string& s) { return s.size(); }, []auto& s) { return sizeof(s); }, }, v); assert(result == 4);
Base Classes
Name |
Description |
|
Member Functions
Name |
Description |
|
For historical reasons we want to support use that looks like a function call: |
Using Declarations
Name |
Deduction Guides
Name |
Description |
Before C++20, which added support for CTAD for aggregate types, we must also teach the compiler how to deduce the template arguments for Overload. |
Created with MrDocs