mercredi 18 septembre 2019

C++ working with a map with vectors as values

I have a map that maps strings to vectors of strings:

std::unordered_map<std::string, std::vector<std::string>>> myMap;.

Is there a nice way (as little code as possible while still being readable) to append a value to the vector of a given key?

How to handle the case of adding a value to a vector for a new key for which the vector hasn't been initialized yet?

Aucun commentaire:

Enregistrer un commentaire