diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /util/generic/maybe.h | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/maybe.h')
-rw-r--r-- | util/generic/maybe.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 34d21aebcd..b07de3b3b5 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -222,7 +222,7 @@ public: } ~TMaybe() = default; - + constexpr TMaybe& operator=(const TMaybe&) = default; constexpr TMaybe& operator=(TMaybe&&) = default; @@ -238,9 +238,9 @@ public: } else { Init(std::forward<U>(right)); } - return *this; - } - + return *this; + } + template <class U> std::enable_if_t<TCopyAssignable<U>::value, TMaybe&> @@ -289,16 +289,16 @@ public: this->Defined_ = false; Data()->~T(); } - } - + } + constexpr bool Defined() const noexcept { return this->Defined_; } - + Y_PURE_FUNCTION constexpr bool Empty() const noexcept { return !Defined(); - } - + } + void CheckDefined() const { if (Y_UNLIKELY(!Defined())) { Policy::OnEmpty(typeid(TValueType)); @@ -314,17 +314,17 @@ public: } constexpr const T& GetRef() const& { - CheckDefined(); + CheckDefined(); return *Data(); - } - + } + constexpr T& GetRef() & { - CheckDefined(); + CheckDefined(); return *Data(); - } - + } + constexpr const T&& GetRef() const&& { CheckDefined(); @@ -340,11 +340,11 @@ public: constexpr const T& operator*() const& { return GetRef(); } - + constexpr T& operator*() & { return GetRef(); - } - + } + constexpr const T&& operator*() const&& { return std::move(GetRef()); } @@ -355,8 +355,8 @@ public: constexpr const T* operator->() const { return &GetRef(); - } - + } + constexpr T* operator->() { return &GetRef(); } @@ -384,8 +384,8 @@ public: constexpr explicit operator bool() const noexcept { return Defined(); - } - + } + void Save(IOutputStream* out) const { const bool defined = Defined(); |