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

Converts a variant to a variant of another set of types&period;

== Synopsis

Declared in `&lt;absl&sol;types&sol;variant&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename To,
    typename Variant&gt;
To
ConvertVariantTo(Variant&& variant);
----

== Description

Each alternative of the target variant must be constructible from any type held by the source variant&period;

Example&colon;

std&colon;&colon;variant&lt;name1, name2, float&gt; InternalReq(const Req&amp;)&semi;

&sol;&sol; name1 and name2 are convertible to name std&colon;&colon;variant&lt;name, float&gt; ExternalReq(const Req&amp; req) &lcub; return absl&colon;&colon;ConvertVariantTo&lt;std&colon;&colon;variant&lt;name, float&gt;&gt;( InternalReq(req))&semi; &rcub;

== Return Value

A `To` constructed from the active alternative of `variant`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *variant*
| The source variant to convert&period;
|===


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