samedi 28 février 2015

Adding into unordered map containing vector value


Let's say I have an unordered map defined as this:



unordered_map<string, vector<Obj*>> map // I defined some Obj class


If I were to add an element into the map, I would have to do something like:



pair<string, vector<Obj*>> newEntry(myString, myVector);
map.insert(newEntry);


But I just want to add an element into the vector, what can I do? Do I have to pull out the vector and add to it before inserting it again? What is the best way to do this?




Aucun commentaire:

Enregistrer un commentaire