diff options
author | kvk1920 <kvk1920@yandex-team.com> | 2023-12-05 16:14:48 +0300 |
---|---|---|
committer | kvk1920 <kvk1920@yandex-team.com> | 2023-12-05 17:21:07 +0300 |
commit | 747e11878ae60c06720f08748a4ea304c45d70a3 (patch) | |
tree | f0ad51fd0dad6b94c37d55712def9653bf35d296 | |
parent | dc89a27e3362ea9e929edfab9c317db6c39734f8 (diff) | |
download | ydb-747e11878ae60c06720f08748a4ea304c45d70a3.tar.gz |
Require EMasterReign to be monotonic
-rw-r--r-- | library/cpp/yt/misc/enum-inl.h | 8 | ||||
-rw-r--r-- | library/cpp/yt/misc/enum.h | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h index 0fcce62067..02493d7ac5 100644 --- a/library/cpp/yt/misc/enum-inl.h +++ b/library/cpp/yt/misc/enum-inl.h @@ -49,9 +49,6 @@ constexpr bool CheckValuesMonotonic(const TValues& values) template <typename TValues> constexpr bool CheckValuesUnique(const TValues& values) { - if (CheckValuesMonotonic(values)) { - return true; - } for (size_t i = 0; i < std::size(values); ++i) { for (size_t j = i + 1; j < std::size(values); ++j) { if (values[i] == values[j]) { @@ -106,6 +103,9 @@ constexpr bool CheckDomainNames(const TNames& names) PP_FOR_EACH(ENUM__GET_DOMAIN_VALUES_ITEM, seq) \ }}; \ \ + [[maybe_unused]] static constexpr bool IsMonotonic = \ + ::NYT::NDetail::CheckValuesMonotonic(Values); \ + \ static TStringBuf GetTypeName() \ { \ static constexpr TStringBuf Result = PP_STRINGIZE(enumType); \ @@ -185,7 +185,7 @@ constexpr bool CheckDomainNames(const TNames& names) TStringBuf(PP_STRINGIZE(item)), #define ENUM__VALIDATE_UNIQUE(enumType) \ - static_assert(::NYT::NDetail::CheckValuesUnique(Values), \ + static_assert(IsMonotonic || ::NYT::NDetail::CheckValuesUnique(Values), \ "Enumeration " #enumType " contains duplicate values"); #define ENUM__END_TRAITS(enumType) \ diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h index a881f22941..1494ca7907 100644 --- a/library/cpp/yt/misc/enum.h +++ b/library/cpp/yt/misc/enum.h @@ -55,6 +55,7 @@ struct TEnumTraits static constexpr bool IsEnum = false; static constexpr bool IsBitEnum = false; static constexpr bool IsStringSerializableEnum = false; + static constexpr bool IsMonotonic = false; }; template <class T> @@ -83,6 +84,7 @@ struct TEnumTraits<T, true> static constexpr bool IsEnum = true; static constexpr bool IsBitEnum = TEnumTraitsImpl<T>::IsBitEnum; static constexpr bool IsStringSerializableEnum = TEnumTraitsImpl<T>::IsStringSerializableEnum; + static constexpr bool IsMonotonic = TEnumTraitsImpl<T>::IsMonotonic; static TStringBuf GetTypeName(); |