From: Mikko Rasa Date: Fri, 24 May 2019 16:58:39 +0000 (+0300) Subject: Add a version of get_item that dynamic_casts the result X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6fe08a456236d5c0f0231df2d50783d2b529b831;p=libs%2Fcore.git Add a version of get_item that dynamic_casts the result --- diff --git a/source/core/maputils.h b/source/core/maputils.h index 2495a1e..66b4e3b 100644 --- a/source/core/maputils.h +++ b/source/core/maputils.h @@ -74,6 +74,12 @@ const typename T::mapped_type &get_item(const T &map, const typename T::key_type return i->second; } +template +D *get_item(const T &map, const typename T::key_type &key) +{ + return dynamic_cast(get_item(map, key)); +} + template typename T::iterator insert_unique(T &map, const typename T::key_type &key, const typename T::mapped_type &item) {