I have:
- A base abstract class Shape.
- Then, several child classes, one of them, Rectangle.
- A template class called GeneralObject<T>, having a private member T shape (T has a static assert check for being child of Shape), in order for a GeneralObject to be created:
GeneralObject<Rectangle>
- An ObjectManager which I want to include a vector of GeneralObject(s).
How should I implement this functionality in order to have this vector of Template classes with arbitrary shapes?
I suppose that one way is to remove the static assert from 3) and create something like:
std::vector<GeneralObject <std::shared_ptr<Shape>>> objects;
but I am not sure if I am following the proper approach. It would be great if I could also assert that the template function uses a child of Shape.
Aucun commentaire:
Enregistrer un commentaire