mercredi 30 janvier 2019

Storing templated objects in a vector (Storing Class

There is a templated class, let it be

template<typename T> class A { std::vector<T> data; };

The problem I am facing here is, users can create several types of this class, but I need to track them, best case is I have a reference of these objets in another vector, but that would not work since all types are different. Can you recommend a good design pattern which can encapsulate this.

I can store pointers and then typecast it, but its not elegant.

Aucun commentaire:

Enregistrer un commentaire