X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmaputils.h;h=2495a1e29b41854e62850324d80fa358ffe2e152;hb=b4664bc8a51e2b78e9325feecc196a426ac4fc38;hp=0f863b46fdf7dea307f251be4823a4e63cdcbc4e;hpb=676f6faa92d23c2096a6a85cac819925dbdc1a88;p=libs%2Fcore.git diff --git a/source/core/maputils.h b/source/core/maputils.h index 0f863b4..2495a1e 100644 --- a/source/core/maputils.h +++ b/source/core/maputils.h @@ -75,7 +75,7 @@ const typename T::mapped_type &get_item(const T &map, const typename T::key_type } template -const typename T::iterator insert_unique(T &map, const typename T::key_type &key, const typename T::mapped_type &item) +typename T::iterator insert_unique(T &map, const typename T::key_type &key, const typename T::mapped_type &item) { if(map.count(key)) throw key_error(key); @@ -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 +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