diff options
author | babenko <babenko@yandex-team.com> | 2024-10-27 18:54:07 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-10-27 19:11:40 +0300 |
commit | 1c41d6078d76a7a377b39d42e99aac3aa034479d (patch) | |
tree | 13f789a76ff26231039dfed7a8ced091b3268a7d /library/cpp/yt/misc/enum.h | |
parent | b9951884f7c336f1462711cd8ad93645ac0d6d70 (diff) | |
download | ydb-1c41d6078d76a7a377b39d42e99aac3aa034479d.tar.gz |
Add GetAllSetValue and IsKnownValue
commit_hash:cbc39112d8384b8c4bcd2410f0a203466b400c10
Diffstat (limited to 'library/cpp/yt/misc/enum.h')
-rw-r--r-- | library/cpp/yt/misc/enum.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h index f78d23a06d..d9611b2823 100644 --- a/library/cpp/yt/misc/enum.h +++ b/library/cpp/yt/misc/enum.h @@ -69,6 +69,8 @@ struct TEnumTraitsWithKnownDomain<T, /*DomainSizeKnown*/ true> requires (!TEnumTraitsImpl<T>::IsBitEnum); // For bit enums only. + static constexpr T GetAllSetValue() + requires (TEnumTraitsImpl<T>::IsBitEnum); static std::vector<T> Decompose(T value) requires (TEnumTraitsImpl<T>::IsBitEnum); }; @@ -87,6 +89,8 @@ struct TEnumTraits<T, true> static constexpr std::optional<T> TryGetUnknownValue(); static std::optional<TStringBuf> FindLiteralByValue(T value); static std::optional<T> FindValueByLiteral(TStringBuf literal); + static constexpr bool IsKnownValue(T value) + requires (!TEnumTraitsImpl<T>::IsBitEnum); static TString ToString(T value); static T FromString(TStringBuf literal); @@ -127,10 +131,11 @@ struct TEnumTraits<T, true> */ #define DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(enumType, underlyingType, seq) \ ENUM__CLASS(enumType, underlyingType, seq) \ + ENUM__BITWISE_OPS(enumType) \ ENUM__BEGIN_TRAITS(enumType, underlyingType, true, false, seq) \ ENUM__VALIDATE_UNIQUE(enumType) \ + ENUM__ALL_SET_VALUE(enumType, seq) \ ENUM__END_TRAITS(enumType) \ - ENUM__BITWISE_OPS(enumType) \ static_assert(true) //! Defines a smart enumeration with a specific underlying type. @@ -142,9 +147,10 @@ struct TEnumTraits<T, true> */ #define DEFINE_AMBIGUOUS_BIT_ENUM_WITH_UNDERLYING_TYPE(enumType, underlyingType, seq) \ ENUM__CLASS(enumType, underlyingType, seq) \ + ENUM__BITWISE_OPS(enumType) \ ENUM__BEGIN_TRAITS(enumType, underlyingType, true, false, seq) \ + ENUM__ALL_SET_VALUE(enumType, seq) \ ENUM__END_TRAITS(enumType) \ - ENUM__BITWISE_OPS(enumType) \ static_assert(true) //! Defines a smart enumeration with the default |unsigned int| underlying type. |