X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmaputils.h;h=1b36c69569b6973992d381c7d39060e412341c89;hb=be67e7f4a28332bfab44d0cbc9f008e24ddf3510;hp=1a7c0ae6ce8e952d1ab9b10113e47172dc4b3136;hpb=c7afef88380ebebc8c2b04e48664d73281ec8848;p=libs%2Fcore.git diff --git a/source/core/maputils.h b/source/core/maputils.h index 1a7c0ae..1b36c69 100644 --- a/source/core/maputils.h +++ b/source/core/maputils.h @@ -33,6 +33,15 @@ const typename T::mapped_type &get_item(const T &map, const typename T::key_type return i->second; } +template +const 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(typeid(T)); + + return map.insert(typename T::value_type(key, item)).first; +} + } // namespace Msp #endif