mardi 23 janvier 2018

Constructor with template arguments

I have a Dynamic class that can store different types : int, double, std::vector<int>, std::vector<double>, etc. I have about 50 of such types.

I would like my Dynamic type to have a constructor where we give two informations:

  • The type to be stored
  • Arguments used to construct the type inside the Dynamic class

I am looking forward to something such as

const Dynamic x<std::vector<double>>{10};

to construct in place a Dynamic object that has a std::vector<double> of length 10.

PS: I am allowed to use C++11 and I am not allowed to use RTTI

Aucun commentaire:

Enregistrer un commentaire