How to modify key values in std::map container
Given std::map<int,std::string> myMap; fillMyMapWithStuff(myMap); // modify key values - I need to add a constant value to each key for (std::map<int,std::string>::iterator mi=myMap.begin(); mi != myMap.end(); ++mi) { // ... } Whats a good way apply some re-indexing? Must I remove the old entry and add a new one with the new key and old value? Looks like you are better off building a new map and swapping it afterward. You'll have only n insert operations instead of n deletions and n insertions. Yes, you have to remove the old entry and add a new one with the new key. Keys are not modifiable.