dimanche 27 octobre 2019

Allow map to accept int, bool and string as values

I created a map so I could use it like a dictionary in python. My problem is that I would like alpha to accept not only int, but also bool or string. so alpha could be true/false or "chad". I understand std::string, int is restponsible for it, but I can't figure out how to accept multiple values. (or any)

std::map<std::string, int> mymap = {
              { "alpha", 0 },
              { "beta", 0 },
              { "gamma", 0 } };

Aucun commentaire:

Enregistrer un commentaire