aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/enum-inl.h
diff options
context:
space:
mode:
authorignatloskutov <ignatloskutov@yandex-team.com>2023-03-17 19:47:20 +0300
committerignatloskutov <ignatloskutov@yandex-team.com>2023-03-17 19:47:20 +0300
commitc3bc8550ac88edbc52a40da723595ced3ad0c7c7 (patch)
treef7ebe585e3ad57cdf5f53a09e468a0d58cce5f4b /library/cpp/yt/misc/enum-inl.h
parent26147c4e01ae75f397d4dd999da238bf2c61c851 (diff)
downloadydb-c3bc8550ac88edbc52a40da723595ced3ad0c7c7.tar.gz
YT-18571: fix YT enums' uniqueness check
Otherwise, enums like this compile successfully: ``` DEFINE_ENUM(ENonUnique, ((Foo1) (0)) ((Foo2) (0)) ((Foo3) (0)) ((Foo4) (0)) ); ```
Diffstat (limited to 'library/cpp/yt/misc/enum-inl.h')
-rw-r--r--library/cpp/yt/misc/enum-inl.h10
1 files changed, 1 insertions, 9 deletions
diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h
index ba33290e79..951e93c130 100644
--- a/library/cpp/yt/misc/enum-inl.h
+++ b/library/cpp/yt/misc/enum-inl.h
@@ -41,15 +41,7 @@ namespace NDetail {
template <typename TValues>
constexpr bool CheckValuesMonotonic(const TValues& values)
{
- if (std::size(values) <= 1) {
- return true;
- }
- for (size_t i = 0; i < std::size(values) - 1; ++i) {
- if (values[i] > values[i + 1]) {
- return false;
- }
- }
- return true;
+ return std::adjacent_find(values.begin(), values.end(), std::greater_equal<>()) == values.end();
}
template <typename TValues>