From 6fe08a456236d5c0f0231df2d50783d2b529b831 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 24 May 2019 19:58:39 +0300 Subject: [PATCH] Add a version of get_item that dynamic_casts the result --- source/core/maputils.h | 6 ++++++ 1 file changed, 6 insertions(+) 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) { -- 2.45.2