I have two base abstract classes A, and B what is inherited from A. B contains a map argument with generic type, and I would like to create children from A and B and store that in a deque:
class A {
};
template <typename T>
class B : public A {
std::map<const char *, T> data;
virtual void doEvent(const char *) = 0;
};
class C : public A {
};
class D : public B<char> {
void doEvent(const char *event) {
// use map<const char*, char>
}
};
class E : public B<int> {
void doEvent(const char *event) {
// use map<const char*, int>
}
};
std::deque<A *> as;
void main() {
for (auto &it : as) {
//if (it instanceof B) {
// cast it to B
// call B.doEvent("myEvent")
//}
}
}
Could somebody help me how to check that a child is inherited from B , ignoring T type. How could I use std::is_base_of or dynamic_cast with generic type.
Thanks