[#absl-Overload-05]
= xref:absl.adoc[absl]::Overload
:relfileprefix: ../
:mrdocs:

`absl&colon;&colon;Overload` is a functor that provides overloads based on the functors with which it is created&period; This can, for example, be used to locally define an anonymous visitor type for `std&colon;&colon;visit` inside a function using lambdas&period;

== Synopsis

Declared in `&lt;absl&sol;functional&sol;overload&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename&period;&period;&period; T&gt;
struct Overload final
    : T&period;&period;&period;
----

== Description

Before using this function, consider whether named function overloads would be a better design&period;

Example&colon;

std&colon;&colon;variant&lt;std&colon;&colon;string, int32&lowbar;t, int64&lowbar;t&gt; v(int32&lowbar;t&lcub;1&rcub;)&semi; const size&lowbar;t result &equals; std&colon;&colon;visit(absl&colon;&colon;Overload&lcub; &lsqb;&rsqb;std&colon;&colon;string&amp; s) &lcub; return s&period;size()&semi; &rcub;, &lsqb;&rsqb;auto&amp; s) &lcub; return sizeof(s)&semi; &rcub;, &rcub;, v)&semi; assert(result &equals;&equals; 4)&semi;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `T&period;&period;&period;`
| 
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Overload-05/2constructor.adoc[`Overload`]         [.small]#[constructor]#
| For historical reasons we want to support use that looks like a function call&colon;
|===


== Using Declarations

[cols="1"]
|===
| Name
| xref:absl/Overload-05/operator().adoc[`operator()`] 
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:absl/Overload-0a.adoc[`Overload&lt;T&period;&period;&period;&gt;`] 
| Before C&plus;&plus;20, which added support for CTAD for aggregate types, we must also teach the compiler how to deduce the template arguments for Overload&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
