std::shared_ptr allows for polymorphism of the stored type, for instance:
class A {};
class B: public A {};
I can have std::vector<std::shared_ptr<A>> that holds B objects.
But what if I want to take this a step further and make A a template and store std::shared_ptrs of different specializations of A. For instance:
template<typename T> class A {};
class Strategy {};
class StrategyOne : public Strategy {};
class StrategyTwo : public Strategy {};
Is it possible to have a std::vector<std::shared_ptr<A<Strategy>>> that can store StrategyOne and StrategyTwo type objects at the same time?
Aucun commentaire:
Enregistrer un commentaire