diff options
author | babenko <babenko@yandex-team.com> | 2024-10-26 23:13:30 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-10-26 23:30:14 +0300 |
commit | 41d598c624442bf6918407466dac3316b8277347 (patch) | |
tree | 5895b8823d4f887e1e5ab4f99cbac991dca5ca17 /library/cpp/yt/misc/enum-inl.h | |
parent | ddabd4ddff87ac13bfc87ef02af352216a0f4e13 (diff) | |
download | ydb-41d598c624442bf6918407466dac3316b8277347.tar.gz |
YT-22885: DEFINE_ENUM_UNKNOWN_VALUE, string-related conversions
commit_hash:14c7e42422af750383f04855b4a7ea6b267b92d2
Diffstat (limited to 'library/cpp/yt/misc/enum-inl.h')
-rw-r--r-- | library/cpp/yt/misc/enum-inl.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h index 5e1d04da1f..6ad9273293 100644 --- a/library/cpp/yt/misc/enum-inl.h +++ b/library/cpp/yt/misc/enum-inl.h @@ -38,6 +38,14 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// +template <class T> +constexpr std::optional<T> TryGetEnumUnknownValueImpl(T) +{ + return std::nullopt; +} + +//////////////////////////////////////////////////////////////////////////////// + namespace NDetail { template <typename TValues> @@ -262,6 +270,13 @@ TStringBuf TEnumTraits<T, true>::GetTypeName() } template <class T> +constexpr std::optional<T> TEnumTraits<T, true>::TryGetUnknownValue() +{ + using NYT::TryGetEnumUnknownValueImpl; + return TryGetEnumUnknownValueImpl(T()); +} + +template <class T> std::optional<T> TEnumTraits<T, true>::FindValueByLiteral(TStringBuf literal) { return TEnumTraitsImpl<T>::FindValueByLiteral(literal); |