vendredi 5 juin 2015

Vector of templated maps in C++11

I am trying to do something that I thought should initially be trivial, but am running into design problems on how I should ideally structure this. I want to create a map of key-value pairs that stores a bunch of parameters. The "key" in here is always a string. However the value could be an int, double, string or char. I have enums to define the type:

typedef enum {INT = 0, DOUBLE, STRING, CHAR} val_type;

I was thinking of structuring it as a vector of maps

std::vector<std::map<std::string, T>> params;

What is the most principled way to go about this?

EDIT: Updated the vector declaration.

Aucun commentaire:

Enregistrer un commentaire