Last active
December 18, 2015 04:49
-
-
Save psycharo-zz/5728665 to your computer and use it in GitHub Desktop.
insert and replace in the map if an entry already exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* insert and replace if an entry already exists | |
*/ | |
template <class TKey, class TVal> | |
void map_insert(std::map<TKey, TVal> &values, const std::pair<TKey, TVal> &val) | |
{ | |
std::pair<typename std::map<TKey,TVal>::iterator, bool> res = values.insert(val); | |
if (!res.second) | |
res.first->second = val.second; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment