Lets assume we have some collections:
struct A { virtual ~A(); };
struct B : A {};
struct C1 : B {};
struct C2 : B {};
struct C3 : A {};
std::vector< C1 > c1s;
std::vector< C2 > c2s;
std::vector< C3 > c3s;
Is it now possible to create a Handle template class that access c1s, c2s, c3s via an index?
Handle< C1 >, Handle< C2 > and Handle< C3 > are trivial. But is it somehow possible to cast Handle< C1 > and Handle< C2 > to Handle< B > while still accessing the right vectors (though returning B* or B&)? Similarly, is it somehow possible to cast Handle< C1 >, Handle< C2 >, Handle< C3 > and Handle< B > to Handle< A > while still accessing the right vectors (though returning A* or A&)? (Mis)using std::type_index?
↧