#include <variant>
struct A
{
void foo(){}
};
struct B
{
void foo(){}
};
int main()
{
std::variant< A, B > v{ A{} };
v.foo(); // doesn't work
}
How do I use the std::variant
value not knowing it's type but knowing it's properties? I believe this is called Generic Polymorphism equivalent to Duck Typing.