aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-04-11 15:09:13 +0300
committerarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-04-11 15:26:32 +0300
commitc69c158e5a3d1a39602cf1497af47a20786106a4 (patch)
treea86e009e7d78729005c02dc62e955f62bd58da52 /library
parent450e62a01220775eef49b15c7ad0ddba4160a2b1 (diff)
downloadydb-c69c158e5a3d1a39602cf1497af47a20786106a4.tar.gz
YT-19731: Whitelist now prevents dropping inner errors with whitelisted attributes
No tests for now 9e6aa6815b8d892d1e76281e95f5d044196801e1
Diffstat (limited to 'library')
-rw-r--r--library/cpp/yt/misc/optional.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/library/cpp/yt/misc/optional.h b/library/cpp/yt/misc/optional.h
index cfae5c36d5..d5e3c07fbe 100644
--- a/library/cpp/yt/misc/optional.h
+++ b/library/cpp/yt/misc/optional.h
@@ -13,6 +13,16 @@ struct TOptionalTraits
{
using TOptional = std::optional<T>;
using TValue = T;
+
+ static constexpr bool HasValue(const TOptional& opt)
+ {
+ return opt.has_value();
+ }
+
+ static constexpr TOptional Empty()
+ {
+ return std::nullopt;
+ }
};
template <class T>
@@ -20,6 +30,16 @@ struct TOptionalTraits<std::optional<T>>
{
using TOptional = std::optional<T>;
using TValue = T;
+
+ static constexpr bool HasValue(const TOptional& opt)
+ {
+ return opt.has_value();
+ }
+
+ static constexpr TOptional Empty()
+ {
+ return std::nullopt;
+ }
};
template <class T>
@@ -27,6 +47,16 @@ struct TOptionalTraits<T*>
{
using TOptional = T*;
using TValue = T*;
+
+ static constexpr bool HasValue(const TOptional& opt)
+ {
+ return opt != nullptr;
+ }
+
+ static constexpr TOptional Empty()
+ {
+ return nullptr;
+ }
};
template <class T>
@@ -34,6 +64,16 @@ struct TOptionalTraits<TIntrusivePtr<T>>
{
using TOptional = TIntrusivePtr<T>;
using TValue = TIntrusivePtr<T>;
+
+ static bool HasValue(const TOptional& opt)
+ {
+ return opt.Get() != nullptr;
+ }
+
+ static constexpr TOptional Empty()
+ {
+ return TIntrusivePtr<T>{};
+ }
};
////////////////////////////////////////////////////////////////////////////////