From b6a00f927c0e4cc51ebc7303033cdcea45c3d267 Mon Sep 17 00:00:00 2001 From: swarmer Date: Sat, 16 Dec 2023 03:34:20 +0300 Subject: [PATCH] detect dangling references in TMaybe object --- util/generic/maybe.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 633eb1b8435..8498afda348 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -306,75 +306,75 @@ class TMaybe: private TMaybeBase { } } - const T* Get() const noexcept { + const T* Get() const noexcept Y_LIFETIME_BOUND { return Defined() ? Data() : nullptr; } - T* Get() noexcept { + T* Get() noexcept Y_LIFETIME_BOUND { return Defined() ? Data() : nullptr; } - constexpr const T& GetRef() const& { + constexpr const T& GetRef() const& Y_LIFETIME_BOUND { CheckDefined(); return *Data(); } - constexpr T& GetRef() & { + constexpr T& GetRef() & Y_LIFETIME_BOUND { CheckDefined(); return *Data(); } - constexpr const T&& GetRef() const&& { + constexpr const T&& GetRef() const&& Y_LIFETIME_BOUND { CheckDefined(); return std::move(*Data()); } - constexpr T&& GetRef() && { + constexpr T&& GetRef() && Y_LIFETIME_BOUND { CheckDefined(); return std::move(*Data()); } - constexpr const T& operator*() const& { + constexpr const T& operator*() const& Y_LIFETIME_BOUND { return GetRef(); } - constexpr T& operator*() & { + constexpr T& operator*() & Y_LIFETIME_BOUND { return GetRef(); } - constexpr const T&& operator*() const&& { + constexpr const T&& operator*() const&& Y_LIFETIME_BOUND { return std::move(GetRef()); } - constexpr T&& operator*() && { + constexpr T&& operator*() && Y_LIFETIME_BOUND { return std::move(GetRef()); } - constexpr const T* operator->() const { + constexpr const T* operator->() const Y_LIFETIME_BOUND { return &GetRef(); } - constexpr T* operator->() { + constexpr T* operator->() Y_LIFETIME_BOUND { return &GetRef(); } - constexpr const T& GetOrElse(const T& elseValue) const { + constexpr const T& GetOrElse(const T& elseValue Y_LIFETIME_BOUND) const Y_LIFETIME_BOUND { return Defined() ? *Data() : elseValue; } - constexpr T& GetOrElse(T& elseValue) { + constexpr T& GetOrElse(T& elseValue Y_LIFETIME_BOUND) Y_LIFETIME_BOUND { return Defined() ? *Data() : elseValue; } - constexpr const TMaybe& OrElse(const TMaybe& elseValue) const noexcept { + constexpr const TMaybe& OrElse(const TMaybe& elseValue Y_LIFETIME_BOUND) const noexcept Y_LIFETIME_BOUND { return Defined() ? *this : elseValue; } - constexpr TMaybe& OrElse(TMaybe& elseValue) { + constexpr TMaybe& OrElse(TMaybe& elseValue Y_LIFETIME_BOUND) Y_LIFETIME_BOUND { return Defined() ? *this : elseValue; } @@ -434,11 +434,11 @@ class TMaybe: private TMaybeBase { } private: - constexpr const T* Data() const noexcept { + constexpr const T* Data() const noexcept Y_LIFETIME_BOUND { return std::addressof(this->Data_); } - constexpr T* Data() noexcept { + constexpr T* Data() noexcept Y_LIFETIME_BOUND { return std::addressof(this->Data_); }