[#absl-ConvertVariantTo] = xref:absl.adoc[absl]::ConvertVariantTo :relfileprefix: ../ :mrdocs: Converts a variant to a variant of another set of types. == Synopsis Declared in `<absl/types/variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename To, typename Variant> To ConvertVariantTo(Variant&& variant); ---- == Description Each alternative of the target variant must be constructible from any type held by the source variant. Example: std::variant<name1, name2, float> InternalReq(const Req&); // name1 and name2 are convertible to name std::variant<name, float> ExternalReq(const Req& req) { return absl::ConvertVariantTo<std::variant<name, float>>( InternalReq(req)); } == Return Value A `To` constructed from the active alternative of `variant`. == Parameters [cols="1,4"] |=== | Name| Description | *variant* | The source variant to convert. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#