I have the following code:
std::variant<A, B> foo();
std::variant<A, B, C> bar();
std::variant<A, B, C> foobar(bool a) {
if (a) {
return foo();
} else {
return bar();
}
}
However, this doesn't compile on gcc:
error: could not convert ‘foo()’ from ‘variant<A, B>’ to ‘variant<A,B,C>’.
Is there an elegant way to convert std::variant<A, B>
into std::variant<A, B, C>
?