Converts a variant to a variant of another set of types.
Synopsis
Declared in <absl/types/variant.h>
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
Name |
Description |
variant |
The source variant to convert. |
Created with MrDocs