projects
/
libs
/
core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c73d8ee
)
Add a function to remove an item from a map, checking for existence
author
Mikko Rasa
<tdb@tdb.fi>
Wed, 6 Nov 2013 09:23:31 +0000
(11:23 +0200)
committer
Mikko Rasa
<tdb@tdb.fi>
Wed, 6 Nov 2013 09:24:28 +0000
(11:24 +0200)
source/core/maputils.h
patch
|
blob
|
history
diff --git
a/source/core/maputils.h
b/source/core/maputils.h
index 0f863b46fdf7dea307f251be4823a4e63cdcbc4e..ecee0fbea45955dbf9bef8f8bf296bb387b3e414 100644
(file)
--- a/
source/core/maputils.h
+++ b/
source/core/maputils.h
@@
-83,6
+83,15
@@
const typename T::iterator insert_unique(T &map, const typename T::key_type &key
return map.insert(typename T::value_type(key, item)).first;
}
+template<typename T>
+void remove_existing(T &map, const typename T::key_type &key)
+{
+ if(!map.count(key))
+ throw key_error(key);
+
+ map.erase(key);
+}
+
} // namespace Msp
#endif