|
@@ -1,5 +1,7 @@
|
|
|
#pragma once
|
|
|
|
|
|
+#include <util/system/compiler.h>
|
|
|
+
|
|
|
#include <type_traits>
|
|
|
#include <utility>
|
|
|
|
|
@@ -12,14 +14,14 @@ if (T* value = MapFindPtr(myMap, someKey) {
|
|
|
*/
|
|
|
|
|
|
template <class Map, class K>
|
|
|
-inline auto MapFindPtr(Map& map, const K& key) {
|
|
|
+inline auto MapFindPtr(Map& map Y_LIFETIME_BOUND, 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) {
|
|
|
+inline auto MapFindPtr(const Map& map Y_LIFETIME_BOUND, const K& key) {
|
|
|
auto i = map.find(key);
|
|
|
|
|
|
return (i == map.end() ? nullptr : &i->second);
|
|
@@ -29,12 +31,12 @@ inline auto MapFindPtr(const Map& map, const K& key) {
|
|
|
template <class Derived>
|
|
|
struct TMapOps {
|
|
|
template <class K>
|
|
|
- inline auto FindPtr(const K& key) {
|
|
|
+ inline auto FindPtr(const K& key) Y_LIFETIME_BOUND {
|
|
|
return MapFindPtr(static_cast<Derived&>(*this), key);
|
|
|
}
|
|
|
|
|
|
template <class K>
|
|
|
- inline auto FindPtr(const K& key) const {
|
|
|
+ inline auto FindPtr(const K& key) const Y_LIFETIME_BOUND {
|
|
|
return MapFindPtr(static_cast<const Derived&>(*this), key);
|
|
|
}
|
|
|
|
|
@@ -45,7 +47,7 @@ struct TMapOps {
|
|
|
}
|
|
|
|
|
|
template <class K, class V>
|
|
|
- inline const V& ValueRef(const K& key, V& defaultValue) const {
|
|
|
+ inline const V& ValueRef(const K& key, V& defaultValue Y_LIFETIME_BOUND) const Y_LIFETIME_BOUND {
|
|
|
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.");
|
|
|
|
|
|
if (auto found = FindPtr(key)) {
|
|
@@ -55,5 +57,5 @@ struct TMapOps {
|
|
|
}
|
|
|
|
|
|
template <class K, class V>
|
|
|
- inline const V& ValueRef(const K& key, V&& defaultValue) const = delete;
|
|
|
+ inline const V& ValueRef(const K& key, V&& defaultValue Y_LIFETIME_BOUND) const Y_LIFETIME_BOUND = delete;
|
|
|
};
|