For this code:
struct A {};
struct B {};
auto f() -> std::variant<A, B>
{
if (true) return A();
return B();
}
Is it possible for a compiler to automatically deduce return type as std::variant<A,B>
?
Just so return type declaration can be omitted:
auto f() // std::variant<A, B> deduced by compiler
{
if (true) return A();
return B();
}