I have a map of vectors:
std::map<int, std::vector<bool>> mymap
At times, I need to insert a new element:
auto& newvec = mymap[42];
// Add stuff to newvec
As far is I understand (and assuming that 42 is not yet in the map), this will give me newvec with length 0 (constructed as std::vector<bool> {}) which I can then extend.
Is there a way to initialize the vector to some size n right away?
(I am not concerned about performance, just wondering if there is a way to do this).
Aucun commentaire:
Enregistrer un commentaire