diff options
author | swarmer <swarmer@yandex-team.com> | 2023-12-15 17:08:08 +0300 |
---|---|---|
committer | swarmer <swarmer@yandex-team.com> | 2023-12-15 19:34:46 +0300 |
commit | b009ee7c484628cd91409b1d7b328e38aa4e4079 (patch) | |
tree | a4a338cad0c4aa623db34614ce28535c3177302f /util/generic/utility.h | |
parent | ed88f5773993cad8389038c006bbad44bb757ad5 (diff) | |
download | ydb-b009ee7c484628cd91409b1d7b328e38aa4e4079.tar.gz |
detect dangling references in MapFindPtr and utility helpers
Diffstat (limited to 'util/generic/utility.h')
-rw-r--r-- | util/generic/utility.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/util/generic/utility.h b/util/generic/utility.h index 43b98eeafc..5362fd4e42 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -2,31 +2,33 @@ #include "typetraits.h" +#include <util/system/compiler.h> + #include <cstring> template <class T> -static constexpr const T& Min(const T& l, const T& r) { +static constexpr const T& Min(const T& l Y_LIFETIME_BOUND, const T& r Y_LIFETIME_BOUND) { return r < l ? r : l; } template <typename T, typename... Args> -static constexpr const T& Min(const T& a, const T& b, const Args&... args) { +static constexpr const T& Min(const T& a Y_LIFETIME_BOUND, const T& b Y_LIFETIME_BOUND, const Args&... args Y_LIFETIME_BOUND) { return Min(a, Min(b, args...)); } template <class T> -static constexpr const T& Max(const T& l, const T& r) { +static constexpr const T& Max(const T& l Y_LIFETIME_BOUND, const T& r Y_LIFETIME_BOUND) { return l < r ? r : l; } template <typename T, typename... Args> -static constexpr const T& Max(const T& a, const T& b, const Args&... args) { +static constexpr const T& Max(const T& a Y_LIFETIME_BOUND, const T& b Y_LIFETIME_BOUND, const Args&... args Y_LIFETIME_BOUND) { return Max(a, Max(b, args...)); } // replace with http://en.cppreference.com/w/cpp/algorithm/clamp in c++17 template <class T> -constexpr const T& ClampVal(const T& val, const T& min, const T& max) { +constexpr const T& ClampVal(const T& val Y_LIFETIME_BOUND, const T& min Y_LIFETIME_BOUND, const T& max Y_LIFETIME_BOUND) { return val < min ? min : (max < val ? max : val); } |