diff options
author | dobrokot <dobrokot@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
commit | 25d83bf841d8b3ce3886525078f1964ac3c293c5 (patch) | |
tree | bd52fa16c8dd727890b2ef9d87d1a402bd0d3a9a /util/generic/mapfindptr.h | |
parent | 1d2e8a8e9976488ea69a7e4763aa749244f82612 (diff) | |
download | ydb-25d83bf841d8b3ce3886525078f1964ac3c293c5.tar.gz |
Restoring authorship annotation for <dobrokot@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/mapfindptr.h')
-rw-r--r-- | util/generic/mapfindptr.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/util/generic/mapfindptr.h b/util/generic/mapfindptr.h index bc10cac60f..fdacd9e997 100644 --- a/util/generic/mapfindptr.h +++ b/util/generic/mapfindptr.h @@ -1,41 +1,41 @@ -#pragma once - +#pragma once + #include <type_traits> -/** MapFindPtr usage: - -if (T* value = MapFindPtr(myMap, someKey) { - Cout << *value; -} - -*/ - +/** MapFindPtr usage: + +if (T* value = MapFindPtr(myMap, someKey) { + Cout << *value; +} + +*/ + template <class Map, class K> inline auto MapFindPtr(Map& map, const K& key) { auto i = map.find(key); return (i == map.end() ? nullptr : &i->second); -} - +} + template <class Map, class K> inline auto MapFindPtr(const Map& map, const K& key) { auto i = map.find(key); return (i == map.end() ? nullptr : &i->second); -} - +} + /** helper for THashMap/TMap */ template <class Derived> -struct TMapOps { +struct TMapOps { template <class K> inline auto FindPtr(const K& key) { - return MapFindPtr(static_cast<Derived&>(*this), key); - } + return MapFindPtr(static_cast<Derived&>(*this), key); + } template <class K> inline auto FindPtr(const K& key) const { - return MapFindPtr(static_cast<const Derived&>(*this), key); - } + return MapFindPtr(static_cast<const Derived&>(*this), key); + } template <class K, class DefaultValue> inline auto Value(const K& key, const DefaultValue& defaultValue) const -> std::remove_reference_t<decltype(*this->FindPtr(key))> { @@ -57,4 +57,4 @@ struct TMapOps { template <class K, class V> inline const V& ValueRef(const K& key, V&& defaultValue) const = delete; -}; +}; |