MCPcopy Create free account
hub / github.com/catboost/catboost / TMapOps

Class TMapOps

util/generic/mapfindptr.h:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30/** helper for THashMap/TMap */
31template <class Derived>
32struct TMapOps {
33 template <class K>
34 inline auto FindPtr(const K& key) Y_LIFETIME_BOUND {
35 return MapFindPtr(static_cast<Derived&>(*this), key);
36 }
37
38 template <class K>
39 inline auto FindPtr(const K& key) const Y_LIFETIME_BOUND {
40 return MapFindPtr(static_cast<const Derived&>(*this), key);
41 }
42
43 template <class K, class DefaultValue>
44 inline auto Value(const K& key, DefaultValue&& defaultValue) const {
45 auto found = FindPtr(key);
46 return found ? *found : std::forward<DefaultValue>(defaultValue);
47 }
48
49 template <class K, class V>
50 inline const V& ValueRef(const K& key, V& defaultValue Y_LIFETIME_BOUND) const Y_LIFETIME_BOUND {
51 static_assert(std::is_same<std::remove_const_t<V>, typename Derived::mapped_type>::value, "Passed default value must have the same type as the underlying map's mapped_type.");
52
53 if (auto found = FindPtr(key)) {
54 return *found;
55 }
56 return defaultValue;
57 }
58
59 template <class K, class V>
60 inline const V& ValueRef(const K& key, V&& defaultValue Y_LIFETIME_BOUND) const Y_LIFETIME_BOUND = delete;
61};

Callers

nothing calls this directly

Calls 1

FindPtrFunction · 0.85

Tested by

no test coverage detected