How can I have a variant of different objects A, B, C
where C
has a reference to the variant?
class A {
...
};
class B {
...
};
class C {
...
std::vector<PossibleValues> storage; // reference to variant
...
};
boost::variant<A, B, C> PossibleValues;
With correct order, you might have:
class A {
//...
};
class B {
//...
};
class C;
using PossibleValues = std::variant<A, B, C>;
class C {
//...
std::vector<PossibleValues> storage; // reference to variant
//...
};