Getting a value from a std::variant that matches the type fetched from another variant

1 · Raymond Chen · June 20, 2019, 2 p.m.
Suppose you have two std::variant objects of the same type and you want to perform some operation on corresponding pairs of types. using my_variant = std::variant<int, double, std::string>; bool are_equivalent(my_variant const& left, my_variant const& right) { if (left.index() != right.index()) return false; The post Getting a value from a <CODE>std::variant</CODE> that matches the type fetched from another variant appeared first on The Old New Thing....