X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fmaputils.h;h=1b36c69569b6973992d381c7d39060e412341c89;hp=1a7c0ae6ce8e952d1ab9b10113e47172dc4b3136;hb=79482ba7aea1b79c7a310c940cc0292532ef3bcb;hpb=5e440d3753a43641b90f521849851aa7f286793c 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