aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-02-10 16:46:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:31 +0300
commit11a24635da4c4f39428b182c49a7bc35e47c9534 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util
parent317da38588b7898a99fd9168571408123350012b (diff)
downloadydb-11a24635da4c4f39428b182c49a7bc35e47c9534.tar.gz
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/benchmark/to_lower/metrics/ya.make2
-rw-r--r--util/charset/benchmark/utf8_to_wide/metrics/ya.make2
-rw-r--r--util/charset/benchmark/ya.make2
-rw-r--r--util/charset/ut/ya.make2
-rw-r--r--util/charset/ya.make10
-rw-r--r--util/datetime/ut/ya.make2
-rw-r--r--util/datetime/ya.make10
-rw-r--r--util/digest/ut/ya.make2
-rw-r--r--util/digest/ya.make10
-rw-r--r--util/draft/ut/ya.make2
-rw-r--r--util/draft/ya.make10
-rw-r--r--util/folder/fwd.cpp2
-rw-r--r--util/folder/fwd.h10
-rw-r--r--util/folder/path.h2
-rw-r--r--util/folder/tempdir.h2
-rw-r--r--util/folder/ut/ya.make2
-rw-r--r--util/folder/ya.make10
-rw-r--r--util/generic/algorithm.h56
-rw-r--r--util/generic/algorithm_ut.cpp40
-rw-r--r--util/generic/array_ref.h20
-rw-r--r--util/generic/array_ref_ut.cpp10
-rw-r--r--util/generic/benchmark/fastclp2/metrics/ya.make2
-rw-r--r--util/generic/benchmark/fastclp2/ya.make2
-rw-r--r--util/generic/benchmark/log2/metrics/ya.make2
-rw-r--r--util/generic/benchmark/log2/ya.make2
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/ya.make2
-rw-r--r--util/generic/benchmark/rotate_bits/ya.make2
-rw-r--r--util/generic/benchmark/singleton/ya.make2
-rw-r--r--util/generic/benchmark/smart_pointers/ya.make2
-rw-r--r--util/generic/benchmark/sort/ya.make2
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/ya.make2
-rw-r--r--util/generic/benchmark/vector_count_ctor/ya.make2
-rw-r--r--util/generic/benchmark/ya.make2
-rw-r--r--util/generic/fuzz/vector/ya.make2
-rw-r--r--util/generic/hash.cpp8
-rw-r--r--util/generic/hash.h102
-rw-r--r--util/generic/hash_primes.cpp180
-rw-r--r--util/generic/hash_primes.h240
-rw-r--r--util/generic/hash_primes_ut.cpp136
-rw-r--r--util/generic/hash_ut.cpp2
-rw-r--r--util/generic/maybe.cpp8
-rw-r--r--util/generic/maybe.h50
-rw-r--r--util/generic/maybe_ut.cpp12
-rw-r--r--util/generic/ptr_ut.cpp118
-rw-r--r--util/generic/scope.h6
-rw-r--r--util/generic/serialized_enum.cpp2
-rw-r--r--util/generic/serialized_enum.h720
-rw-r--r--util/generic/serialized_enum_ut.cpp218
-rw-r--r--util/generic/strbuf_ut.cpp24
-rw-r--r--util/generic/string.h8
-rw-r--r--util/generic/string_ut.h26
-rw-r--r--util/generic/typetraits.h4
-rw-r--r--util/generic/typetraits_ut.cpp10
-rw-r--r--util/generic/ut/ya.make4
-rw-r--r--util/generic/utility.h4
-rw-r--r--util/generic/utility_ut.cpp22
-rw-r--r--util/generic/vector_ut.cpp6
-rw-r--r--util/generic/xrange.h32
-rw-r--r--util/generic/xrange_ut.cpp120
-rw-r--r--util/generic/ya.make10
-rw-r--r--util/generic/yexception.cpp18
-rw-r--r--util/generic/yexception.h82
-rw-r--r--util/generic/yexception_ut.cpp104
-rw-r--r--util/memory/addstorage.h74
-rw-r--r--util/memory/benchmark/pool/metrics/ya.make2
-rw-r--r--util/memory/benchmark/pool/ya.make2
-rw-r--r--util/memory/benchmark/ya.make2
-rw-r--r--util/memory/blob.h12
-rw-r--r--util/memory/ut/ya.make2
-rw-r--r--util/memory/ya.make10
-rw-r--r--util/network/ut/ya.make2
-rw-r--r--util/network/ya.make10
-rw-r--r--util/random/benchmark/prng/metrics/ya.make2
-rw-r--r--util/random/benchmark/prng/ya.make2
-rw-r--r--util/random/benchmark/ya.make2
-rw-r--r--util/random/ut/ya.make2
-rw-r--r--util/random/ya.make10
-rw-r--r--util/stream/ut/ya.make2
-rw-r--r--util/stream/ya.make10
-rw-r--r--util/string/benchmark/float_to_string/metrics/ya.make2
-rw-r--r--util/string/benchmark/join/metrics/ya.make2
-rw-r--r--util/string/benchmark/join/ya.make2
-rw-r--r--util/string/benchmark/subst_global/metrics/ya.make2
-rw-r--r--util/string/benchmark/ya.make2
-rw-r--r--util/string/fuzzing/collapse/ya.make2
-rw-r--r--util/string/fuzzing/escape_c/ya.make2
-rw-r--r--util/string/fuzzing/strtod/ya.make2
-rw-r--r--util/string/fuzzing/ya.make2
-rw-r--r--util/string/join.h6
-rw-r--r--util/string/join_ut.cpp8
-rw-r--r--util/string/split.h22
-rw-r--r--util/string/split_ut.cpp18
-rw-r--r--util/string/ut/ya.make2
-rw-r--r--util/string/ya.make10
-rw-r--r--util/system/atexit.cpp32
-rw-r--r--util/system/benchmark/cpu_id/metrics/ya.make2
-rw-r--r--util/system/benchmark/cpu_id/ya.make2
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/ya.make2
-rw-r--r--util/system/benchmark/rdtsc/ya.make2
-rw-r--r--util/system/benchmark/ya.make2
-rw-r--r--util/system/guard_ut.cpp16
-rw-r--r--util/system/sanitizers.h6
-rw-r--r--util/system/src_location.h10
-rw-r--r--util/system/src_location_ut.cpp6
-rw-r--r--util/system/src_root.h62
-rw-r--r--util/system/src_root_ut.cpp28
-rw-r--r--util/system/ut/stdin_osfhandle/ya.make2
-rw-r--r--util/system/ut/ya.make2
-rw-r--r--util/system/ya.make10
-rw-r--r--util/system/yassert.cpp38
-rw-r--r--util/tests/benchmark/ya.make2
-rw-r--r--util/tests/cython/ya.make2
-rw-r--r--util/tests/fuzzing/ya.make2
-rw-r--r--util/tests/sym_versions/ya.make2
-rw-r--r--util/tests/ut/ya.make2
-rw-r--r--util/thread/lfqueue_ut.cpp2
-rw-r--r--util/thread/ut/ya.make2
-rw-r--r--util/thread/ya.make10
-rw-r--r--util/ya.make12
-rw-r--r--util/ysaveload.cpp16
-rw-r--r--util/ysaveload.h48
-rw-r--r--util/ysaveload_ut.cpp108
122 files changed, 1585 insertions, 1585 deletions
diff --git a/util/charset/benchmark/to_lower/metrics/ya.make b/util/charset/benchmark/to_lower/metrics/ya.make
index ca5b897fb8..5bb3461a8d 100644
--- a/util/charset/benchmark/to_lower/metrics/ya.make
+++ b/util/charset/benchmark/to_lower/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
agorodilov
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/charset/benchmark/utf8_to_wide/metrics/ya.make b/util/charset/benchmark/utf8_to_wide/metrics/ya.make
index 68d2375faa..c406e25bee 100644
--- a/util/charset/benchmark/utf8_to_wide/metrics/ya.make
+++ b/util/charset/benchmark/utf8_to_wide/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
agorodilov
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/charset/benchmark/ya.make b/util/charset/benchmark/ya.make
index 8c196a78d4..de3e04ef22 100644
--- a/util/charset/benchmark/ya.make
+++ b/util/charset/benchmark/ya.make
@@ -2,7 +2,7 @@ OWNER(
agorodilov
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
to_lower
diff --git a/util/charset/ut/ya.make b/util/charset/ut/ya.make
index ebe677d957..6526815e92 100644
--- a/util/charset/ut/ya.make
+++ b/util/charset/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util/charset)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
DATA(arcadia/util/charset/ut/utf8)
diff --git a/util/charset/ya.make b/util/charset/ya.make
index db9b410b20..26d38cb10b 100644
--- a/util/charset/ya.make
+++ b/util/charset/ya.make
@@ -1,7 +1,7 @@
LIBRARY()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
NO_UTIL()
@@ -29,7 +29,7 @@ ELSE()
ENDIF()
END()
-
-RECURSE_FOR_TESTS(
- ut
-)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/datetime/ut/ya.make b/util/datetime/ut/ya.make
index ed001b4a8f..c2bc714059 100644
--- a/util/datetime/ut/ya.make
+++ b/util/datetime/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
datetime/base_ut.cpp
diff --git a/util/datetime/ya.make b/util/datetime/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/datetime/ya.make
+++ b/util/datetime/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/digest/ut/ya.make b/util/digest/ut/ya.make
index 70c141ccf9..245b2cf6d2 100644
--- a/util/digest/ut/ya.make
+++ b/util/digest/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
digest/fnv_ut.cpp
diff --git a/util/digest/ya.make b/util/digest/ya.make
index 10b832449d..e378a7e419 100644
--- a/util/digest/ya.make
+++ b/util/digest/ya.make
@@ -1,12 +1,12 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PROVIDES(cityhash)
-
+
RECURSE(
benchmark
)
-RECURSE_FOR_TESTS(
- ut
-)
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/draft/ut/ya.make b/util/draft/ut/ya.make
index 5b8693e478..37ab9413c5 100644
--- a/util/draft/ut/ya.make
+++ b/util/draft/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCDIR(util/draft)
diff --git a/util/draft/ya.make b/util/draft/ya.make
index 5d101f9f05..e00674b682 100644
--- a/util/draft/ya.make
+++ b/util/draft/ya.make
@@ -1,7 +1,7 @@
LIBRARY()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
NO_UTIL()
@@ -20,7 +20,7 @@ SRCS(
)
END()
-
-RECURSE_FOR_TESTS(
- ut
-)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/folder/fwd.cpp b/util/folder/fwd.cpp
index 2261ef316c..4214b6df83 100644
--- a/util/folder/fwd.cpp
+++ b/util/folder/fwd.cpp
@@ -1 +1 @@
-#include "fwd.h"
+#include "fwd.h"
diff --git a/util/folder/fwd.h b/util/folder/fwd.h
index 85e61b3150..8b1869a2d9 100644
--- a/util/folder/fwd.h
+++ b/util/folder/fwd.h
@@ -1,5 +1,5 @@
-#pragma once
-
-class TFsPath;
-
-class TTempDir;
+#pragma once
+
+class TFsPath;
+
+class TTempDir;
diff --git a/util/folder/path.h b/util/folder/path.h
index 18d9f82b13..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "pathsplit.h"
#include <util/generic/ptr.h>
diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h
index 14da1f90e6..ff458f83b9 100644
--- a/util/folder/tempdir.h
+++ b/util/folder/tempdir.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "path.h"
#include <util/generic/string.h>
diff --git a/util/folder/ut/ya.make b/util/folder/ut/ya.make
index 24aa46d703..64877d9b58 100644
--- a/util/folder/ut/ya.make
+++ b/util/folder/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
folder/dirut_ut.cpp
diff --git a/util/folder/ya.make b/util/folder/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/folder/ya.make
+++ b/util/folder/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index 62b32731e6..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -83,16 +83,16 @@ static inline void StableSort(TContainer& container, TCompare compare) {
StableSort(container.begin(), container.end(), compare);
}
-template <class TIterator, typename TGetKey>
-static inline void StableSortBy(TIterator begin, TIterator end, const TGetKey& getKey) {
+template <class TIterator, typename TGetKey>
+static inline void StableSortBy(TIterator begin, TIterator end, const TGetKey& getKey) {
StableSort(begin, end, [&](auto&& left, auto&& right) { return getKey(left) < getKey(right); });
-}
-
-template <class TContainer, typename TGetKey>
-static inline void StableSortBy(TContainer& container, const TGetKey& getKey) {
- StableSortBy(container.begin(), container.end(), getKey);
-}
-
+}
+
+template <class TContainer, typename TGetKey>
+static inline void StableSortBy(TContainer& container, const TGetKey& getKey) {
+ StableSortBy(container.begin(), container.end(), getKey);
+}
+
template <class T>
static inline void PartialSort(T f, T m, T l) {
std::partial_sort(f, m, l);
@@ -135,9 +135,9 @@ static inline auto FindPtr(I f, I l, const T& v) -> decltype(&*f) {
template <class C, class T>
static inline auto FindPtr(C&& c, const T& v) {
- using std::begin;
- using std::end;
- return FindPtr(begin(c), end(c), v);
+ using std::begin;
+ using std::end;
+ return FindPtr(begin(c), end(c), v);
}
template <class I, class P>
@@ -160,9 +160,9 @@ static inline bool AllOf(I f, I l, P pred) {
template <class C, class P>
static inline bool AllOf(const C& c, P pred) {
- using std::begin;
- using std::end;
- return AllOf(begin(c), end(c), pred);
+ using std::begin;
+ using std::end;
+ return AllOf(begin(c), end(c), pred);
}
template <class I, class P>
@@ -172,9 +172,9 @@ static inline bool AnyOf(I f, I l, P pred) {
template <class C, class P>
static inline bool AnyOf(const C& c, P pred) {
- using std::begin;
- using std::end;
- return AnyOf(begin(c), end(c), pred);
+ using std::begin;
+ using std::end;
+ return AnyOf(begin(c), end(c), pred);
}
// FindIfPtr - return NULL if not found. Works for arrays, containers, iterators
@@ -186,17 +186,17 @@ static inline auto FindIfPtr(I f, I l, P pred) -> decltype(&*f) {
template <class C, class P>
static inline auto FindIfPtr(C&& c, P pred) {
- using std::begin;
- using std::end;
- return FindIfPtr(begin(c), end(c), pred);
+ using std::begin;
+ using std::end;
+ return FindIfPtr(begin(c), end(c), pred);
}
template <class C, class T>
static inline size_t FindIndex(C&& c, const T& x) {
- using std::begin;
- using std::end;
- auto it = Find(begin(c), end(c), x);
- return it == end(c) ? NPOS : (it - begin(c));
+ using std::begin;
+ using std::end;
+ auto it = Find(begin(c), end(c), x);
+ return it == end(c) ? NPOS : (it - begin(c));
}
template <class C, class P>
@@ -650,9 +650,9 @@ static inline auto CountIf(It first, It last, P p) {
template <class C, class P>
static inline auto CountIf(const C& c, P pred) {
- using std::begin;
- using std::end;
- return CountIf(begin(c), end(c), pred);
+ using std::begin;
+ using std::end;
+ return CountIf(begin(c), end(c), pred);
}
template <class I1, class I2>
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 35ef7cfe35..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -13,11 +13,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne));
UNIT_ASSERT(1 == AnyOf(TStringBuf("11"), isOne));
UNIT_ASSERT(0 == AnyOf(TStringBuf(), isOne));
-
- const char array00[]{'0', '0'};
- UNIT_ASSERT(0 == AnyOf(array00, isOne));
- const char array01[]{'0', '1'};
- UNIT_ASSERT(1 == AnyOf(array01, isOne));
+
+ const char array00[]{'0', '0'};
+ UNIT_ASSERT(0 == AnyOf(array00, isOne));
+ const char array01[]{'0', '1'};
+ UNIT_ASSERT(1 == AnyOf(array01, isOne));
}
Y_UNIT_TEST(AllOfTest) {
@@ -26,11 +26,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne));
UNIT_ASSERT(1 == AllOf(TStringBuf("11"), isOne));
UNIT_ASSERT(1 == AllOf(TStringBuf(), isOne));
-
- const char array01[]{'0', '1'};
- UNIT_ASSERT(0 == AllOf(array01, isOne));
- const char array11[]{'1', '1'};
- UNIT_ASSERT(1 == AllOf(array11, isOne));
+
+ const char array01[]{'0', '1'};
+ UNIT_ASSERT(0 == AllOf(array01, isOne));
+ const char array11[]{'1', '1'};
+ UNIT_ASSERT(1 == AllOf(array11, isOne));
}
Y_UNIT_TEST(CountIfTest) {
@@ -39,9 +39,9 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne));
UNIT_ASSERT(0 == CountIf(TStringBuf(), isOne));
UNIT_ASSERT(1 == CountIf(TStringBuf("1"), isOne));
-
- const char array[] = "____1________1____1_______";
- UNIT_ASSERT(3 == CountIf(array, isOne));
+
+ const char array[] = "____1________1____1_______";
+ UNIT_ASSERT(3 == CountIf(array, isOne));
}
Y_UNIT_TEST(CountTest) {
@@ -51,9 +51,9 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(0 == Count(TStringBuf("___________"), '1'));
UNIT_ASSERT(0 == Count(TStringBuf(), '1'));
UNIT_ASSERT(1 == Count(TStringBuf("1"), '1'));
-
- const char array[] = "____1________1____1_______";
- UNIT_ASSERT(3 == Count(array, '1'));
+
+ const char array[] = "____1________1____1_______";
+ UNIT_ASSERT(3 == Count(array, '1'));
}
struct TStrokaNoCopy: TString {
@@ -510,11 +510,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(StableSortByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
- StableSortBy(collection, [](int x) { return x / 100; });
+ StableSortBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
- UNIT_ASSERT_VALUES_EQUAL(collection, expected);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(collection, expected);
+ }
+
Y_UNIT_TEST(SortUniqueByTest) {
TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h
index f8bc42e179..1ac60ac7d3 100644
--- a/util/generic/array_ref.h
+++ b/util/generic/array_ref.h
@@ -35,39 +35,39 @@ public:
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- constexpr inline TArrayRef() noexcept
+ constexpr inline TArrayRef() noexcept
: T_(nullptr)
, S_(0)
{
}
- constexpr inline TArrayRef(T* data, size_t len) noexcept
+ constexpr inline TArrayRef(T* data, size_t len) noexcept
: T_(data)
, S_(len)
{
}
- constexpr inline TArrayRef(T* begin, T* end) noexcept
+ constexpr inline TArrayRef(T* begin, T* end) noexcept
: T_(begin)
, S_(end - begin)
{
}
- constexpr inline TArrayRef(std::initializer_list<T> list) noexcept
+ constexpr inline TArrayRef(std::initializer_list<T> list) noexcept
: T_(list.begin())
, S_(list.size())
{
}
template <class Container>
- constexpr inline TArrayRef(Container&& container, decltype(std::declval<T*&>() = container.data(), nullptr) = nullptr) noexcept
+ constexpr inline TArrayRef(Container&& container, decltype(std::declval<T*&>() = container.data(), nullptr) = nullptr) noexcept
: T_(container.data())
, S_(container.size())
{
}
template <size_t N>
- constexpr inline TArrayRef(T (&array)[N]) noexcept
+ constexpr inline TArrayRef(T (&array)[N]) noexcept
: T_(array)
, S_(N)
{
@@ -250,12 +250,12 @@ TArrayRef<char> as_writable_bytes(TArrayRef<T> arrayRef) noexcept {
}
template <class Range>
-constexpr TArrayRef<const typename Range::value_type> MakeArrayRef(const Range& range) {
+constexpr TArrayRef<const typename Range::value_type> MakeArrayRef(const Range& range) {
return TArrayRef<const typename Range::value_type>(range);
}
template <class Range>
-constexpr TArrayRef<typename Range::value_type> MakeArrayRef(Range& range) {
+constexpr TArrayRef<typename Range::value_type> MakeArrayRef(Range& range) {
return TArrayRef<typename Range::value_type>(range);
}
@@ -270,11 +270,11 @@ constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& r
}
template <class T>
-constexpr TArrayRef<T> MakeArrayRef(T* data, size_t size) {
+constexpr TArrayRef<T> MakeArrayRef(T* data, size_t size) {
return TArrayRef<T>(data, size);
}
template <class T>
-constexpr TArrayRef<T> MakeArrayRef(T* begin, T* end) {
+constexpr TArrayRef<T> MakeArrayRef(T* begin, T* end) {
return TArrayRef<T>(begin, end);
}
diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp
index b322fd75ae..4c8eaf7135 100644
--- a/util/generic/array_ref_ut.cpp
+++ b/util/generic/array_ref_ut.cpp
@@ -283,10 +283,10 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
Do(a);
UNIT_ASSERT_VALUES_EQUAL(a[0], 8);
}
-
- Y_UNIT_TEST(TestConstexpr) {
- static constexpr const int a[] = {1, 2, -3, -4};
- static constexpr const auto r0 = MakeArrayRef(a, 1);
+
+ Y_UNIT_TEST(TestConstexpr) {
+ static constexpr const int a[] = {1, 2, -3, -4};
+ static constexpr const auto r0 = MakeArrayRef(a, 1);
static_assert(r0.size() == 1, "r0.size() is not equal 1");
static_assert(r0.data()[0] == 1, "r0.data()[0] is not equal to 1");
@@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
static constexpr const TArrayRef<const int> r2 = r1;
static_assert(r2.size() == 4, "r2.size() is not equal to 4");
static_assert(r2.data()[2] == -3, "r2.data()[2] is not equal to -3");
- }
+ }
template <typename T>
static void Foo(const TConstArrayRef<T>) {
diff --git a/util/generic/benchmark/fastclp2/metrics/ya.make b/util/generic/benchmark/fastclp2/metrics/ya.make
index 1a3b73a398..b2d17ebad3 100644
--- a/util/generic/benchmark/fastclp2/metrics/ya.make
+++ b/util/generic/benchmark/fastclp2/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/generic/benchmark/fastclp2/ya.make b/util/generic/benchmark/fastclp2/ya.make
index 7ba0dcee94..976977014f 100644
--- a/util/generic/benchmark/fastclp2/ya.make
+++ b/util/generic/benchmark/fastclp2/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/generic/benchmark/log2/metrics/ya.make b/util/generic/benchmark/log2/metrics/ya.make
index 0e7801fddb..eb987e38d2 100644
--- a/util/generic/benchmark/log2/metrics/ya.make
+++ b/util/generic/benchmark/log2/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/generic/benchmark/log2/ya.make b/util/generic/benchmark/log2/ya.make
index baac034e69..45d751909e 100644
--- a/util/generic/benchmark/log2/ya.make
+++ b/util/generic/benchmark/log2/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/generic/benchmark/rotate_bits/metrics/ya.make b/util/generic/benchmark/rotate_bits/metrics/ya.make
index f16c659236..ac27d2f845 100644
--- a/util/generic/benchmark/rotate_bits/metrics/ya.make
+++ b/util/generic/benchmark/rotate_bits/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/generic/benchmark/rotate_bits/ya.make b/util/generic/benchmark/rotate_bits/ya.make
index 7ba0dcee94..976977014f 100644
--- a/util/generic/benchmark/rotate_bits/ya.make
+++ b/util/generic/benchmark/rotate_bits/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/generic/benchmark/singleton/ya.make b/util/generic/benchmark/singleton/ya.make
index ae6576c52f..12d3d316c8 100644
--- a/util/generic/benchmark/singleton/ya.make
+++ b/util/generic/benchmark/singleton/ya.make
@@ -1,7 +1,7 @@
Y_BENCHMARK()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
f.cpp
diff --git a/util/generic/benchmark/smart_pointers/ya.make b/util/generic/benchmark/smart_pointers/ya.make
index 5628d4fb8a..7059abc3a4 100644
--- a/util/generic/benchmark/smart_pointers/ya.make
+++ b/util/generic/benchmark/smart_pointers/ya.make
@@ -1,7 +1,7 @@
Y_BENCHMARK()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/generic/benchmark/sort/ya.make b/util/generic/benchmark/sort/ya.make
index 5628d4fb8a..7059abc3a4 100644
--- a/util/generic/benchmark/sort/ya.make
+++ b/util/generic/benchmark/sort/ya.make
@@ -1,7 +1,7 @@
Y_BENCHMARK()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/ya.make b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
index a763150b58..c48f89b564 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/generic/benchmark/vector_count_ctor/ya.make b/util/generic/benchmark/vector_count_ctor/ya.make
index 1406f81210..42ce442819 100644
--- a/util/generic/benchmark/vector_count_ctor/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/generic/benchmark/ya.make b/util/generic/benchmark/ya.make
index 98358ad6bd..635860a646 100644
--- a/util/generic/benchmark/ya.make
+++ b/util/generic/benchmark/ya.make
@@ -1,6 +1,6 @@
OWNER(yazevnul g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
fastclp2
diff --git a/util/generic/fuzz/vector/ya.make b/util/generic/fuzz/vector/ya.make
index 9c3ee10b1d..b8614f6411 100644
--- a/util/generic/fuzz/vector/ya.make
+++ b/util/generic/fuzz/vector/ya.make
@@ -4,7 +4,7 @@ OWNER(
pg
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/generic/hash.cpp b/util/generic/hash.cpp
index 10f07c5940..a674ee4538 100644
--- a/util/generic/hash.cpp
+++ b/util/generic/hash.cpp
@@ -45,7 +45,7 @@ TString NPrivate::MapKeyToString(unsigned long long key) {
TString NPrivate::MapKeyToString(long long key) {
return ToString(key);
}
-
-void NPrivate::ThrowKeyNotFoundInHashTableException(const TStringBuf keyRepresentation) {
- ythrow yexception() << "Key not found in hashtable: " << keyRepresentation;
-}
+
+void NPrivate::ThrowKeyNotFoundInHashTableException(const TStringBuf keyRepresentation) {
+ ythrow yexception() << "Key not found in hashtable: " << keyRepresentation;
+}
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 11d157a152..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -219,12 +219,12 @@ public:
using const_iterator = const_pointer;
using size_type = size_t;
using difference_type = ptrdiff_t;
- using TBucketDivisor = ::NPrivate::THashDivisor;
+ using TBucketDivisor = ::NPrivate::THashDivisor;
_yhashtable_buckets(const Alloc& other)
: base_type(other)
, Data(nullptr)
- , Size()
+ , Size()
{
}
@@ -232,13 +232,13 @@ public:
Y_ASSERT(!Data);
}
- void initialize_dynamic(TBucketDivisor size) {
+ void initialize_dynamic(TBucketDivisor size) {
Y_ASSERT(!Data);
- Data = this->_get_alloc().allocate(size() + 2) + 1;
+ Data = this->_get_alloc().allocate(size() + 2) + 1;
Size = size;
- *reinterpret_cast<size_type*>(Data - 1) = size() + 2;
+ *reinterpret_cast<size_type*>(Data - 1) = size() + 2;
}
void deinitialize_dynamic() {
@@ -246,11 +246,11 @@ public:
this->_get_alloc().deallocate(Data - 1, *reinterpret_cast<size_type*>(Data - 1));
Data = pointer();
- Size = TBucketDivisor();
+ Size = TBucketDivisor();
}
- void initialize_static(pointer data, TBucketDivisor size) {
- Y_ASSERT(!Data && data && size() >= 1);
+ void initialize_static(pointer data, TBucketDivisor size) {
+ Y_ASSERT(!Data && data && size() >= 1);
Data = data;
Size = size;
@@ -260,11 +260,11 @@ public:
Y_ASSERT(Data);
Data = pointer();
- Size = TBucketDivisor();
+ Size = TBucketDivisor();
}
- void resize_noallocate(TBucketDivisor size) {
- Y_ASSERT(size() <= capacity());
+ void resize_noallocate(TBucketDivisor size) {
+ Y_ASSERT(size() <= capacity());
Size = size;
}
@@ -276,10 +276,10 @@ public:
return Data;
}
iterator end() {
- return Data + Size();
+ return Data + Size();
}
const_iterator end() const {
- return Data + Size();
+ return Data + Size();
}
pointer data() {
@@ -290,30 +290,30 @@ public:
}
size_type size() const {
- return Size();
+ return Size();
}
size_type capacity() const {
return *reinterpret_cast<size_type*>(Data - 1);
}
- TBucketDivisor ExtSize() const {
- return Size;
- }
- int BucketDivisorHint() const {
- return +Size.Hint;
- }
+ TBucketDivisor ExtSize() const {
+ return Size;
+ }
+ int BucketDivisorHint() const {
+ return +Size.Hint;
+ }
allocator_type get_allocator() const {
return this->_get_alloc();
}
const_reference operator[](size_type index) const {
- Y_ASSERT(index <= Size());
+ Y_ASSERT(index <= Size());
return *(Data + index);
}
reference operator[](size_type index) {
- Y_ASSERT(index <= Size());
+ Y_ASSERT(index <= Size());
return *(Data + index);
}
@@ -329,7 +329,7 @@ private:
pointer Data;
/** Size of the buckets array. Doesn't take the marker element at the end into account. */
- TBucketDivisor Size;
+ TBucketDivisor Size;
};
/**
@@ -455,7 +455,7 @@ class THashTable: private _yhashtable_traits<Value, Key, HashFcn, ExtractKey, Eq
using node = typename traits_type::node;
using nodep_allocator_type = typename traits_type::nodep_allocator_type;
using buckets_type = _yhashtable_buckets<node*, nodep_allocator_type>;
- using TBucketDivisor = ::NPrivate::THashDivisor;
+ using TBucketDivisor = ::NPrivate::THashDivisor;
public:
using key_type = Key;
@@ -560,7 +560,7 @@ public:
if (ht.empty()) {
initialize_buckets(buckets, 0);
} else {
- initialize_buckets_dynamic(buckets, ht.buckets.ExtSize());
+ initialize_buckets_dynamic(buckets, ht.buckets.ExtSize());
copy_from_dynamic(ht);
}
}
@@ -591,10 +591,10 @@ public:
initialize_buckets(buckets, 0);
} else {
if (buckets.capacity() > ht.buckets.size()) {
- buckets.resize_noallocate(ht.buckets.ExtSize());
+ buckets.resize_noallocate(ht.buckets.ExtSize());
} else {
deinitialize_buckets(buckets);
- initialize_buckets_dynamic(buckets, ht.buckets.ExtSize());
+ initialize_buckets_dynamic(buckets, ht.buckets.ExtSize());
}
copy_from_dynamic(ht);
@@ -845,10 +845,10 @@ public:
basic_clear();
if (downsize < buckets.size()) {
- const TBucketDivisor newSize = HashBucketCountExt(downsize);
- if (newSize() < buckets.size()) {
- Y_ASSERT(newSize() >= 7); /* We cannot downsize static buckets. */
- buckets.resize_noallocate(newSize);
+ const TBucketDivisor newSize = HashBucketCountExt(downsize);
+ if (newSize() < buckets.size()) {
+ Y_ASSERT(newSize() >= 7); /* We cannot downsize static buckets. */
+ buckets.resize_noallocate(newSize);
}
}
}
@@ -880,19 +880,19 @@ public:
private:
static void initialize_buckets(buckets_type& buckets, size_type sizeHint) {
if (sizeHint == 0) {
- buckets.initialize_static(reinterpret_cast<node**>(const_cast<void**>(_yhashtable_empty_data)) + 1, TBucketDivisor::One());
+ buckets.initialize_static(reinterpret_cast<node**>(const_cast<void**>(_yhashtable_empty_data)) + 1, TBucketDivisor::One());
} else {
- TBucketDivisor size = HashBucketCountExt(sizeHint);
- Y_ASSERT(size() >= 7);
+ TBucketDivisor size = HashBucketCountExt(sizeHint);
+ Y_ASSERT(size() >= 7);
initialize_buckets_dynamic(buckets, size);
}
}
- static void initialize_buckets_dynamic(buckets_type& buckets, TBucketDivisor size) {
+ static void initialize_buckets_dynamic(buckets_type& buckets, TBucketDivisor size) {
buckets.initialize_dynamic(size);
- memset(buckets.data(), 0, size() * sizeof(*buckets.data()));
- buckets[size()] = (node*)1;
+ memset(buckets.data(), 0, size() * sizeof(*buckets.data()));
+ buckets[size()] = (node*)1;
}
static void deinitialize_buckets(buckets_type& buckets) {
@@ -909,7 +909,7 @@ private:
template <class OtherKey>
size_type bkt_num_key(const OtherKey& key) const {
- return bkt_num_key(key, buckets.ExtSize());
+ return bkt_num_key(key, buckets.ExtSize());
}
template <class OtherValue>
@@ -918,14 +918,14 @@ private:
}
template <class OtherKey>
- size_type bkt_num_key(const OtherKey& key, TBucketDivisor n) const {
- const size_type bucket = n.Remainder(this->_get_hash_fun()(key));
- Y_ASSERT((0 <= bucket) && (bucket < n()));
- return bucket;
+ size_type bkt_num_key(const OtherKey& key, TBucketDivisor n) const {
+ const size_type bucket = n.Remainder(this->_get_hash_fun()(key));
+ Y_ASSERT((0 <= bucket) && (bucket < n()));
+ return bucket;
}
template <class OtherValue>
- size_type bkt_num(const OtherValue& obj, TBucketDivisor n) const {
+ size_type bkt_num(const OtherValue& obj, TBucketDivisor n) const {
return bkt_num_key(get_key(obj), n);
}
@@ -1268,8 +1268,8 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
if (old_n != 1 && num_elements_hint <= old_n) // TODO: this if is for backwards compatibility down to order-in-buckets level. Can be safely removed.
return false;
- const TBucketDivisor n = HashBucketCountExt(num_elements_hint + 1, buckets.BucketDivisorHint() + 1);
- if (n() > old_n) {
+ const TBucketDivisor n = HashBucketCountExt(num_elements_hint + 1, buckets.BucketDivisorHint() + 1);
+ if (n() > old_n) {
buckets_type tmp(buckets.get_allocator());
initialize_buckets_dynamic(tmp, n);
#ifdef __STL_USE_EXCEPTIONS
@@ -1417,8 +1417,8 @@ namespace NPrivate {
inline TString MapKeyToString(char* key) {
return MapKeyToString(TStringBuf(key));
}
-
- [[noreturn]] void ThrowKeyNotFoundInHashTableException(const TStringBuf keyRepresentation);
+
+ [[noreturn]] void ThrowKeyNotFoundInHashTableException(const TStringBuf keyRepresentation);
}
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
@@ -1652,8 +1652,8 @@ public:
using namespace ::NPrivate;
const_iterator it = find(key);
- if (Y_UNLIKELY(it == end())) {
- ::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
+ if (Y_UNLIKELY(it == end())) {
+ ::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
}
return it->second;
@@ -1664,8 +1664,8 @@ public:
using namespace ::NPrivate;
iterator it = find(key);
- if (Y_UNLIKELY(it == end())) {
- ::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
+ if (Y_UNLIKELY(it == end())) {
+ ::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
}
return it->second;
diff --git a/util/generic/hash_primes.cpp b/util/generic/hash_primes.cpp
index 41b23c308c..656d31e046 100644
--- a/util/generic/hash_primes.cpp
+++ b/util/generic/hash_primes.cpp
@@ -2,9 +2,9 @@
#include "array_size.h"
#include "algorithm.h"
-/// Order of fields: reciprocal, reciprocal shift, adjacent hint, divisor
-#if defined(_32_)
-static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
+/// Order of fields: reciprocal, reciprocal shift, adjacent hint, divisor
+#if defined(_32_)
+static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
{0x00000000u, 0u, -1, 0xffffffffu}, // guard value, not a valid divisor
{0x24924925u, 2u, 0, 7u},
{0xe1e1e1e2u, 4u, 1, 17u},
@@ -16,30 +16,30 @@ static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
{0x54e3b41au, 9u, 7, 769u},
{0x53c8eaeeu, 10u, 8, 1543u},
{0x548eacc6u, 11u, 9, 3079u},
- {0x54f1e41eu, 12u, 10, 6151u},
- {0x554e390au, 13u, 11, 12289u},
- {0x5518ee41u, 14u, 12, 24593u},
- {0x554c7203u, 15u, 13, 49157u},
- {0x5549c781u, 16u, 14, 98317u},
- {0x55531c76u, 17u, 15, 196613u},
- {0x554fc734u, 18u, 16, 393241u},
- {0x555538e4u, 19u, 17, 786433u},
- {0x55550e39u, 20u, 18, 1572869u},
- {0x5555071du, 21u, 19, 3145739u},
- {0x5555271du, 22u, 20, 6291469u},
- {0x55554c72u, 23u, 21, 12582917u},
- {0x55554472u, 24u, 22, 25165843u},
- {0x5555531du, 25u, 23, 50331653u},
- {0x55555039u, 26u, 24, 100663319u},
- {0x55555339u, 27u, 25, 201326611u},
- {0x5555550fu, 28u, 26, 402653189u},
- {0x555552ddu, 29u, 27, 805306457u},
- {0x55555544u, 30u, 28, 1610612741u},
- {0x55555554u, 31u, 29, 3221225473u},
- {0x00000006u, 31u, 30, 4294967291u},
-};
-#else
-static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
+ {0x54f1e41eu, 12u, 10, 6151u},
+ {0x554e390au, 13u, 11, 12289u},
+ {0x5518ee41u, 14u, 12, 24593u},
+ {0x554c7203u, 15u, 13, 49157u},
+ {0x5549c781u, 16u, 14, 98317u},
+ {0x55531c76u, 17u, 15, 196613u},
+ {0x554fc734u, 18u, 16, 393241u},
+ {0x555538e4u, 19u, 17, 786433u},
+ {0x55550e39u, 20u, 18, 1572869u},
+ {0x5555071du, 21u, 19, 3145739u},
+ {0x5555271du, 22u, 20, 6291469u},
+ {0x55554c72u, 23u, 21, 12582917u},
+ {0x55554472u, 24u, 22, 25165843u},
+ {0x5555531du, 25u, 23, 50331653u},
+ {0x55555039u, 26u, 24, 100663319u},
+ {0x55555339u, 27u, 25, 201326611u},
+ {0x5555550fu, 28u, 26, 402653189u},
+ {0x555552ddu, 29u, 27, 805306457u},
+ {0x55555544u, 30u, 28, 1610612741u},
+ {0x55555554u, 31u, 29, 3221225473u},
+ {0x00000006u, 31u, 30, 4294967291u},
+};
+#else
+static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
{0x0000000000000000ul, 0u, -1, 0xffffffffu}, // guard value, not a valid divisor
{0x2492492492492493ul, 2u, 0, 7u},
{0xe1e1e1e1e1e1e1e2ul, 4u, 1, 17u},
@@ -51,71 +51,71 @@ static constexpr ::NPrivate::THashDivisor PRIME_DIVISORS_HOLDER[]{
{0x54e3b4194ce65de1ul, 9u, 7, 769u},
{0x53c8eaedea6e7f17ul, 10u, 8, 1543u},
{0x548eacc5e1e6e3fcul, 11u, 9, 3079u},
- {0x54f1e41d7767d70cul, 12u, 10, 6151u},
- {0x554e39097a781d80ul, 13u, 11, 12289u},
- {0x5518ee4079ea6929ul, 14u, 12, 24593u},
- {0x554c72025d459231ul, 15u, 13, 49157u},
- {0x5549c78094504ff3ul, 16u, 14, 98317u},
- {0x55531c757b3c329cul, 17u, 15, 196613u},
- {0x554fc7339753b424ul, 18u, 16, 393241u},
- {0x555538e39097b3f4ul, 19u, 17, 786433u},
- {0x55550e38f25ecd82ul, 20u, 18, 1572869u},
- {0x5555071c83b421d2ul, 21u, 19, 3145739u},
- {0x5555271c78097a6aul, 22u, 20, 6291469u},
- {0x55554c71c757b425ul, 23u, 21, 12582917u},
- {0x55554471c7f25ec7ul, 24u, 22, 25165843u},
- {0x5555531c71cad098ul, 25u, 23, 50331653u},
- {0x55555038e3a1d098ul, 26u, 24, 100663319u},
- {0x55555338e3919098ul, 27u, 25, 201326611u},
- {0x5555550e38e39d0aul, 28u, 26, 402653189u},
- {0x555552dc71cbb1eeul, 29u, 27, 805306457u},
- {0x555555438e38e47cul, 30u, 28, 1610612741u},
- {0x555555538e38e391ul, 31u, 29, 3221225473u},
- {0x000000050000001aul, 31u, 30, 4294967291u},
-};
-#endif
-
-static constexpr const ::NPrivate::THashDivisor* PRIME_DIVISORS = &PRIME_DIVISORS_HOLDER[1]; ///< Address of the first valid divisor
+ {0x54f1e41d7767d70cul, 12u, 10, 6151u},
+ {0x554e39097a781d80ul, 13u, 11, 12289u},
+ {0x5518ee4079ea6929ul, 14u, 12, 24593u},
+ {0x554c72025d459231ul, 15u, 13, 49157u},
+ {0x5549c78094504ff3ul, 16u, 14, 98317u},
+ {0x55531c757b3c329cul, 17u, 15, 196613u},
+ {0x554fc7339753b424ul, 18u, 16, 393241u},
+ {0x555538e39097b3f4ul, 19u, 17, 786433u},
+ {0x55550e38f25ecd82ul, 20u, 18, 1572869u},
+ {0x5555071c83b421d2ul, 21u, 19, 3145739u},
+ {0x5555271c78097a6aul, 22u, 20, 6291469u},
+ {0x55554c71c757b425ul, 23u, 21, 12582917u},
+ {0x55554471c7f25ec7ul, 24u, 22, 25165843u},
+ {0x5555531c71cad098ul, 25u, 23, 50331653u},
+ {0x55555038e3a1d098ul, 26u, 24, 100663319u},
+ {0x55555338e3919098ul, 27u, 25, 201326611u},
+ {0x5555550e38e39d0aul, 28u, 26, 402653189u},
+ {0x555552dc71cbb1eeul, 29u, 27, 805306457u},
+ {0x555555438e38e47cul, 30u, 28, 1610612741u},
+ {0x555555538e38e391ul, 31u, 29, 3221225473u},
+ {0x000000050000001aul, 31u, 30, 4294967291u},
+};
+#endif
+
+static constexpr const ::NPrivate::THashDivisor* PRIME_DIVISORS = &PRIME_DIVISORS_HOLDER[1]; ///< Address of the first valid divisor
static constexpr size_t PRIME_DIVISORS_SIZE = Y_ARRAY_SIZE(PRIME_DIVISORS_HOLDER) - 1; ///< Number of valid divisors without the guarding value
-
+
unsigned long HashBucketCount(unsigned long elementCount) {
- return HashBucketCountExt(elementCount)();
-}
-
-static inline ::NPrivate::THashDivisor HashBucketBoundedSearch(unsigned long elementCount) {
- const auto begin = PRIME_DIVISORS;
- const auto end = PRIME_DIVISORS + PRIME_DIVISORS_SIZE - 1; // adjust range so the last element will be returned if elementCount is bigger than all PRIME_DIVISORS
- return *LowerBoundBy(begin, end, elementCount, std::mem_fn(&::NPrivate::THashDivisor::Divisor));
-}
-
-Y_CONST_FUNCTION
-::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount) {
- if (elementCount <= PRIME_DIVISORS[0]()) {
- return PRIME_DIVISORS[0];
+ return HashBucketCountExt(elementCount)();
+}
+
+static inline ::NPrivate::THashDivisor HashBucketBoundedSearch(unsigned long elementCount) {
+ const auto begin = PRIME_DIVISORS;
+ const auto end = PRIME_DIVISORS + PRIME_DIVISORS_SIZE - 1; // adjust range so the last element will be returned if elementCount is bigger than all PRIME_DIVISORS
+ return *LowerBoundBy(begin, end, elementCount, std::mem_fn(&::NPrivate::THashDivisor::Divisor));
+}
+
+Y_CONST_FUNCTION
+::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount) {
+ if (elementCount <= PRIME_DIVISORS[0]()) {
+ return PRIME_DIVISORS[0];
+ }
+
+ return HashBucketBoundedSearch(elementCount);
+}
+
+Y_CONST_FUNCTION
+::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount, int hint) {
+ if (Y_LIKELY(static_cast<size_t>(hint) < PRIME_DIVISORS_SIZE)) {
+ const int index = hint;
+ const ::NPrivate::THashDivisor* cnd = PRIME_DIVISORS + index;
+ if (Y_LIKELY(elementCount <= cnd->Divisor)) {
+ const ::NPrivate::THashDivisor* prev = cnd - 1;
+ static_assert(~PRIME_DIVISORS[-1].Divisor == 0, "Invalid guard");
+ /*
+ If index == 0 then PRIME_DIVISORS[0] should be returned.
+ Otherwise `cnd` is correct value iff (prev->Divisor < elementCount).
+ Ergo hint is correct if (index == 0 || prev->Divisor < elementCount);
+ But we can set guard's value to -1 and check both conditions at once.
+ */
+ if (Y_LIKELY(prev->Divisor + 1u <= elementCount)) {
+ return *cnd;
+ }
+ }
}
- return HashBucketBoundedSearch(elementCount);
+ return HashBucketBoundedSearch(elementCount);
}
-
-Y_CONST_FUNCTION
-::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount, int hint) {
- if (Y_LIKELY(static_cast<size_t>(hint) < PRIME_DIVISORS_SIZE)) {
- const int index = hint;
- const ::NPrivate::THashDivisor* cnd = PRIME_DIVISORS + index;
- if (Y_LIKELY(elementCount <= cnd->Divisor)) {
- const ::NPrivate::THashDivisor* prev = cnd - 1;
- static_assert(~PRIME_DIVISORS[-1].Divisor == 0, "Invalid guard");
- /*
- If index == 0 then PRIME_DIVISORS[0] should be returned.
- Otherwise `cnd` is correct value iff (prev->Divisor < elementCount).
- Ergo hint is correct if (index == 0 || prev->Divisor < elementCount);
- But we can set guard's value to -1 and check both conditions at once.
- */
- if (Y_LIKELY(prev->Divisor + 1u <= elementCount)) {
- return *cnd;
- }
- }
- }
-
- return HashBucketBoundedSearch(elementCount);
-}
diff --git a/util/generic/hash_primes.h b/util/generic/hash_primes.h
index d2bf12082c..4dc2da0b8f 100644
--- a/util/generic/hash_primes.h
+++ b/util/generic/hash_primes.h
@@ -1,12 +1,12 @@
#pragma once
-#include <util/system/compiler.h>
-#include <util/system/types.h>
-
-#if defined(_MSC_VER) && defined(_M_X64)
+#include <util/system/compiler.h>
+#include <util/system/types.h>
+
+#if defined(_MSC_VER) && defined(_M_X64)
#include <intrin.h>
-#endif
-
+#endif
+
/**
* Calculates the number of buckets for the hash table that will hold the given
* number of elements.
@@ -15,124 +15,124 @@
* @returns Number of buckets, a prime number that is
* greater or equal to `elementCount`.
*/
-Y_CONST_FUNCTION
+Y_CONST_FUNCTION
unsigned long HashBucketCount(unsigned long elementCount);
-
-namespace NPrivate {
-
- /// Implementation of algorithm 4.1 from: Torbjörn Granlund and Peter L. Montgomery. 1994. Division by invariant integers using multiplication.
- /// @see https://gmplib.org/~tege/divcnst-pldi94.pdf
- template <typename TDivisor, typename TDividend, typename MulUnsignedUpper>
- class TReciprocalDivisor {
+
+namespace NPrivate {
+
+ /// Implementation of algorithm 4.1 from: Torbjörn Granlund and Peter L. Montgomery. 1994. Division by invariant integers using multiplication.
+ /// @see https://gmplib.org/~tege/divcnst-pldi94.pdf
+ template <typename TDivisor, typename TDividend, typename MulUnsignedUpper>
+ class TReciprocalDivisor {
static_assert(sizeof(TDivisor) <= sizeof(TDividend), "TDivisor and TDividend should have the same size");
- public:
- constexpr TReciprocalDivisor() noexcept = default;
-
- constexpr TReciprocalDivisor(TDividend reciprocal, ui8 reciprocalShift, i8 hint, TDivisor divisor) noexcept
- : Reciprocal(reciprocal)
- , Divisor(divisor)
- , ReciprocalShift(reciprocalShift)
- , Hint(hint)
- {
- }
-
- /// Return (dividend % Divisor)
- Y_FORCE_INLINE TDividend Remainder(TDividend dividend) const noexcept {
- if (Y_UNLIKELY(Divisor == 1)) {
- return 0;
- }
- TDividend r = dividend - Quotent(dividend) * Divisor;
- return r;
- }
-
- Y_FORCE_INLINE TDivisor operator()() const noexcept {
- return Divisor;
- }
-
- Y_FORCE_INLINE static constexpr TReciprocalDivisor One() noexcept {
- return {1u, 0u, -1, 1u};
- }
-
- private:
- /// returns (dividend / Divisor)
- Y_FORCE_INLINE TDividend Quotent(TDividend dividend) const noexcept {
- const TDividend t = MulUnsignedUpper{}(dividend, Reciprocal);
- const TDividend q = (t + ((dividend - t) >> 1)) >> ReciprocalShift;
- return q;
- }
-
- public:
- TDividend Reciprocal = 0;
- TDivisor Divisor = 0;
- ui8 ReciprocalShift = 0;
- i8 Hint = 0; ///< Additional data: needless for division, but useful for the adjacent divisors search
- };
-
- template <typename T, typename TExtended, size_t shift>
- struct TMulUnsignedUpper {
- /// Return the high bits of the product of two unsigned integers.
- Y_FORCE_INLINE T operator()(T a, T b) const noexcept {
- return (static_cast<TExtended>(a) * static_cast<TExtended>(b)) >> shift;
- }
- };
-
-#if defined(_32_)
- using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui32, TMulUnsignedUpper<ui32, ui64, 32>>;
-#else
+ public:
+ constexpr TReciprocalDivisor() noexcept = default;
+
+ constexpr TReciprocalDivisor(TDividend reciprocal, ui8 reciprocalShift, i8 hint, TDivisor divisor) noexcept
+ : Reciprocal(reciprocal)
+ , Divisor(divisor)
+ , ReciprocalShift(reciprocalShift)
+ , Hint(hint)
+ {
+ }
+
+ /// Return (dividend % Divisor)
+ Y_FORCE_INLINE TDividend Remainder(TDividend dividend) const noexcept {
+ if (Y_UNLIKELY(Divisor == 1)) {
+ return 0;
+ }
+ TDividend r = dividend - Quotent(dividend) * Divisor;
+ return r;
+ }
+
+ Y_FORCE_INLINE TDivisor operator()() const noexcept {
+ return Divisor;
+ }
+
+ Y_FORCE_INLINE static constexpr TReciprocalDivisor One() noexcept {
+ return {1u, 0u, -1, 1u};
+ }
+
+ private:
+ /// returns (dividend / Divisor)
+ Y_FORCE_INLINE TDividend Quotent(TDividend dividend) const noexcept {
+ const TDividend t = MulUnsignedUpper{}(dividend, Reciprocal);
+ const TDividend q = (t + ((dividend - t) >> 1)) >> ReciprocalShift;
+ return q;
+ }
+
+ public:
+ TDividend Reciprocal = 0;
+ TDivisor Divisor = 0;
+ ui8 ReciprocalShift = 0;
+ i8 Hint = 0; ///< Additional data: needless for division, but useful for the adjacent divisors search
+ };
+
+ template <typename T, typename TExtended, size_t shift>
+ struct TMulUnsignedUpper {
+ /// Return the high bits of the product of two unsigned integers.
+ Y_FORCE_INLINE T operator()(T a, T b) const noexcept {
+ return (static_cast<TExtended>(a) * static_cast<TExtended>(b)) >> shift;
+ }
+ };
+
+#if defined(_32_)
+ using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui32, TMulUnsignedUpper<ui32, ui64, 32>>;
+#else
#if defined(Y_HAVE_INT128)
- using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui64, TMulUnsignedUpper<ui64, unsigned __int128, 64>>;
+ using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui64, TMulUnsignedUpper<ui64, unsigned __int128, 64>>;
#elif defined(_MSC_VER) && defined(_M_X64)
- struct TMulUnsignedUpperVCIntrin {
- /// Return the high 64 bits of the product of two 64-bit unsigned integers.
- Y_FORCE_INLINE ui64 operator()(ui64 a, ui64 b) const noexcept {
- return __umulh(a, b);
- }
- };
- using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui64, TMulUnsignedUpperVCIntrin>;
+ struct TMulUnsignedUpperVCIntrin {
+ /// Return the high 64 bits of the product of two 64-bit unsigned integers.
+ Y_FORCE_INLINE ui64 operator()(ui64 a, ui64 b) const noexcept {
+ return __umulh(a, b);
+ }
+ };
+ using THashDivisor = ::NPrivate::TReciprocalDivisor<ui32, ui64, TMulUnsignedUpperVCIntrin>;
#else
- template <typename TDivisor, typename TDividend>
- class TNaiveDivisor {
- public:
- constexpr TNaiveDivisor() noexcept = default;
-
- constexpr TNaiveDivisor(TDivisor divisor) noexcept
- : Divisor(divisor)
- {
- }
-
- constexpr TNaiveDivisor(TDividend reciprocal, ui8 reciprocalShift, i8 hint, TDivisor divisor) noexcept
- : TNaiveDivisor(divisor)
- {
- Y_UNUSED(reciprocal);
- Y_UNUSED(reciprocalShift);
- Y_UNUSED(hint);
- }
-
- Y_FORCE_INLINE TDividend Remainder(TDividend dividend) const noexcept {
- return dividend % Divisor;
- }
-
- Y_FORCE_INLINE TDivisor operator()() const noexcept {
- return Divisor;
- }
-
- Y_FORCE_INLINE static constexpr TNaiveDivisor One() noexcept {
- return {1u};
- }
-
- public:
- TDivisor Divisor = 0;
- static constexpr i8 Hint = -1;
- };
-
- using THashDivisor = ::NPrivate::TNaiveDivisor<ui32, ui64>;
+ template <typename TDivisor, typename TDividend>
+ class TNaiveDivisor {
+ public:
+ constexpr TNaiveDivisor() noexcept = default;
+
+ constexpr TNaiveDivisor(TDivisor divisor) noexcept
+ : Divisor(divisor)
+ {
+ }
+
+ constexpr TNaiveDivisor(TDividend reciprocal, ui8 reciprocalShift, i8 hint, TDivisor divisor) noexcept
+ : TNaiveDivisor(divisor)
+ {
+ Y_UNUSED(reciprocal);
+ Y_UNUSED(reciprocalShift);
+ Y_UNUSED(hint);
+ }
+
+ Y_FORCE_INLINE TDividend Remainder(TDividend dividend) const noexcept {
+ return dividend % Divisor;
+ }
+
+ Y_FORCE_INLINE TDivisor operator()() const noexcept {
+ return Divisor;
+ }
+
+ Y_FORCE_INLINE static constexpr TNaiveDivisor One() noexcept {
+ return {1u};
+ }
+
+ public:
+ TDivisor Divisor = 0;
+ static constexpr i8 Hint = -1;
+ };
+
+ using THashDivisor = ::NPrivate::TNaiveDivisor<ui32, ui64>;
#endif
-#endif
-}
-
-Y_CONST_FUNCTION
-::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount);
-
-Y_CONST_FUNCTION
-::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount, int hint);
+#endif
+}
+
+Y_CONST_FUNCTION
+::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount);
+
+Y_CONST_FUNCTION
+::NPrivate::THashDivisor HashBucketCountExt(unsigned long elementCount, int hint);
diff --git a/util/generic/hash_primes_ut.cpp b/util/generic/hash_primes_ut.cpp
index 6f0315c7dc..7b5bf8b5c9 100644
--- a/util/generic/hash_primes_ut.cpp
+++ b/util/generic/hash_primes_ut.cpp
@@ -2,10 +2,10 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/vector.h>
-#include <util/string/builder.h>
-#include <util/random/fast.h>
-
+#include <util/generic/vector.h>
+#include <util/string/builder.h>
+#include <util/random/fast.h>
+
Y_UNIT_TEST_SUITE(TestHashPrimes) {
Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(1), 7);
@@ -13,68 +13,68 @@ Y_UNIT_TEST_SUITE(TestHashPrimes) {
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(7), 7);
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(8), 17);
}
-
- static TVector<size_t> Numbers() {
- TVector<size_t> numbers;
-
- TFastRng64 rng{961923};
- size_t k = 1;
- for (size_t j = 0; j < 8000; ++j) {
- numbers.push_back(rng.GenRand());
- numbers.push_back(k *= 57);
- }
- for (size_t p = 1; p != 0; p <<= 1) {
- for (size_t offset : {-2, -1, 0, 1, 2}) {
- numbers.push_back(p + offset);
- }
- }
- return numbers;
- }
-
- static TVector<size_t> Divisors() {
- TVector<size_t> divisors;
- divisors.push_back(HashBucketCountExt(0)());
- for (;;) {
- const size_t prevSize = divisors.back();
- const size_t nextSize = HashBucketCountExt(prevSize + 1)();
- if (nextSize <= prevSize) {
- break;
- }
- divisors.push_back(nextSize);
- }
- return divisors;
- }
-
- Y_UNIT_TEST(Remainder) {
- const TVector<size_t> numbers = Numbers();
- const TVector<size_t> divisors = Divisors();
-
- auto testDivisor = [&](const auto& c) {
- for (size_t n : numbers) {
- UNIT_ASSERT_VALUES_EQUAL_C(n % c(), c.Remainder(n), (TStringBuilder() << "n=" << n << "; d=" << c()));
- }
- };
-
- for (size_t d : divisors) {
- const auto c = HashBucketCountExt(d);
- UNIT_ASSERT_VALUES_EQUAL_C(d, c(), (TStringBuilder() << "d=" << d));
- testDivisor(c);
- }
- testDivisor(::NPrivate::THashDivisor::One());
- }
-
- Y_UNIT_TEST(MisleadingHints) {
- TFastRng64 rng{332142};
- TVector<size_t> cases = Numbers();
- for (size_t d : Divisors()) {
- cases.push_back(d);
- }
-
- for (size_t c : cases) {
- for (size_t reps = 0; reps < 3; ++reps) {
- const i8 hint = rng.Uniform(256) - 128;
- UNIT_ASSERT_VALUES_EQUAL_C(HashBucketCountExt(c)(), HashBucketCountExt(c, hint)(), (TStringBuilder() << "c=" << c << "; hint=" << hint));
- }
- }
- }
+
+ static TVector<size_t> Numbers() {
+ TVector<size_t> numbers;
+
+ TFastRng64 rng{961923};
+ size_t k = 1;
+ for (size_t j = 0; j < 8000; ++j) {
+ numbers.push_back(rng.GenRand());
+ numbers.push_back(k *= 57);
+ }
+ for (size_t p = 1; p != 0; p <<= 1) {
+ for (size_t offset : {-2, -1, 0, 1, 2}) {
+ numbers.push_back(p + offset);
+ }
+ }
+ return numbers;
+ }
+
+ static TVector<size_t> Divisors() {
+ TVector<size_t> divisors;
+ divisors.push_back(HashBucketCountExt(0)());
+ for (;;) {
+ const size_t prevSize = divisors.back();
+ const size_t nextSize = HashBucketCountExt(prevSize + 1)();
+ if (nextSize <= prevSize) {
+ break;
+ }
+ divisors.push_back(nextSize);
+ }
+ return divisors;
+ }
+
+ Y_UNIT_TEST(Remainder) {
+ const TVector<size_t> numbers = Numbers();
+ const TVector<size_t> divisors = Divisors();
+
+ auto testDivisor = [&](const auto& c) {
+ for (size_t n : numbers) {
+ UNIT_ASSERT_VALUES_EQUAL_C(n % c(), c.Remainder(n), (TStringBuilder() << "n=" << n << "; d=" << c()));
+ }
+ };
+
+ for (size_t d : divisors) {
+ const auto c = HashBucketCountExt(d);
+ UNIT_ASSERT_VALUES_EQUAL_C(d, c(), (TStringBuilder() << "d=" << d));
+ testDivisor(c);
+ }
+ testDivisor(::NPrivate::THashDivisor::One());
+ }
+
+ Y_UNIT_TEST(MisleadingHints) {
+ TFastRng64 rng{332142};
+ TVector<size_t> cases = Numbers();
+ for (size_t d : Divisors()) {
+ cases.push_back(d);
+ }
+
+ for (size_t c : cases) {
+ for (size_t reps = 0; reps < 3; ++reps) {
+ const i8 hint = rng.Uniform(256) - 128;
+ UNIT_ASSERT_VALUES_EQUAL_C(HashBucketCountExt(c)(), HashBucketCountExt(c, hint)(), (TStringBuilder() << "c=" << c << "; hint=" << hint));
+ }
+ }
+ }
}
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index dec374c4a6..0551d58770 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -722,7 +722,7 @@ void THashTest::TestSizeOf() {
* THashTable are empty. It does rely on knowledge of THashTable internals,
* so if those change, the test will have to be adjusted accordingly. */
- size_t expectedSize = sizeof(uintptr_t) + 3 * sizeof(size_t);
+ size_t expectedSize = sizeof(uintptr_t) + 3 * sizeof(size_t);
UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<int, int>), expectedSize);
UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<std::pair<int, int>, std::pair<int, int>>), expectedSize);
diff --git a/util/generic/maybe.cpp b/util/generic/maybe.cpp
index 4d90243795..43262934f8 100644
--- a/util/generic/maybe.cpp
+++ b/util/generic/maybe.cpp
@@ -3,13 +3,13 @@
[[noreturn]] void NMaybe::TPolicyUndefinedExcept::OnEmpty(const std::type_info& valueTypeInfo) {
ythrow yexception() << "TMaybe is empty, value type: "sv << TypeName(valueTypeInfo);
-}
-
+}
+
[[noreturn]] void NMaybe::TPolicyUndefinedFail::OnEmpty(const std::type_info& valueTypeInfo) {
const TString typeName = TypeName(valueTypeInfo);
Y_FAIL("TMaybe is empty, value type: %s", typeName.c_str());
-}
-
+}
+
template <>
void Out<TNothing>(IOutputStream& o, const TNothing&) {
o << "(empty maybe)";
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index e853c43d97..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -300,7 +300,7 @@ public:
}
void CheckDefined() const {
- if (Y_UNLIKELY(!Defined())) {
+ if (Y_UNLIKELY(!Defined())) {
Policy::OnEmpty(typeid(TValueType));
}
}
@@ -313,46 +313,46 @@ public:
return Defined() ? Data() : nullptr;
}
- constexpr const T& GetRef() const& {
+ constexpr const T& GetRef() const& {
CheckDefined();
return *Data();
}
- constexpr T& GetRef() & {
+ constexpr T& GetRef() & {
CheckDefined();
return *Data();
}
- constexpr const T&& GetRef() const&& {
- CheckDefined();
-
- return std::move(*Data());
- }
-
- constexpr T&& GetRef() && {
- CheckDefined();
-
- return std::move(*Data());
- }
-
- constexpr const T& operator*() const& {
+ constexpr const T&& GetRef() const&& {
+ CheckDefined();
+
+ return std::move(*Data());
+ }
+
+ constexpr T&& GetRef() && {
+ CheckDefined();
+
+ return std::move(*Data());
+ }
+
+ constexpr const T& operator*() const& {
return GetRef();
}
- constexpr T& operator*() & {
+ constexpr T& operator*() & {
return GetRef();
}
- constexpr const T&& operator*() const&& {
- return std::move(GetRef());
- }
-
- constexpr T&& operator*() && {
- return std::move(GetRef());
- }
-
+ constexpr const T&& operator*() const&& {
+ return std::move(GetRef());
+ }
+
+ constexpr T&& operator*() && {
+ return std::move(GetRef());
+ }
+
constexpr const T* operator->() const {
return &GetRef();
}
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index 5769a5f43d..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -201,12 +201,12 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
m4 = std::move(m2);
UNIT_ASSERT(m4.Defined());
UNIT_ASSERT_VALUES_EQUAL(m4->Flag, 2);
-
- // Move value from temporary maybe instance
- TMovable o5 = *MakeMaybe<TMovable>(5);
- UNIT_ASSERT_VALUES_EQUAL(o5.Flag, 5);
- TMovable o6 = MakeMaybe<TMovable>(6).GetRef();
- UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6);
+
+ // Move value from temporary maybe instance
+ TMovable o5 = *MakeMaybe<TMovable>(5);
+ UNIT_ASSERT_VALUES_EQUAL(o5.Flag, 5);
+ TMovable o6 = MakeMaybe<TMovable>(6).GetRef();
+ UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6);
}
Y_UNIT_TEST(TestCast) {
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index 6b028f410d..c2dcff23f6 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -25,7 +25,7 @@ class TPointerTest: public TTestBase {
UNIT_TEST(TestIntrPtr);
UNIT_TEST(TestIntrusiveConvertion);
UNIT_TEST(TestIntrusiveConstConvertion);
- UNIT_TEST(TestIntrusiveConstConstruction);
+ UNIT_TEST(TestIntrusiveConstConstruction);
UNIT_TEST(TestMakeIntrusive);
UNIT_TEST(TestCopyOnWritePtr1);
UNIT_TEST(TestCopyOnWritePtr2);
@@ -77,7 +77,7 @@ private:
void TestIntrPtr();
void TestIntrusiveConvertion();
void TestIntrusiveConstConvertion();
- void TestIntrusiveConstConstruction();
+ void TestIntrusiveConstConstruction();
void TestMakeIntrusive();
void TestCopyOnWritePtr1();
void TestCopyOnWritePtr2();
@@ -776,60 +776,60 @@ void TPointerTest::TestRefCountedPtrsInHashSet() {
TestRefCountedPtrsInHashSetImpl<A, TIntrusivePtr<A, TCustomIntrusivePtrOps>>();
TestRefCountedPtrsInHashSetImpl<A, TIntrusiveConstPtr<A, TCustomIntrusivePtrOps>>();
}
-
-class TRefCountedWithStatistics: public TNonCopyable {
-public:
- struct TExternalCounter {
- TAtomic Counter{0};
- TAtomic Increments{0};
- };
-
- TRefCountedWithStatistics(TExternalCounter& cnt)
- : ExternalCounter_(cnt)
- {
- ExternalCounter_ = {}; // reset counters
- }
-
- void Ref() noexcept {
- AtomicIncrement(ExternalCounter_.Counter);
- AtomicIncrement(ExternalCounter_.Increments);
- }
-
- void UnRef() noexcept {
- if (AtomicDecrement(ExternalCounter_.Counter) == 0) {
- TDelete::Destroy(this);
- }
- }
-
- void DecRef() noexcept {
- Y_VERIFY(AtomicDecrement(ExternalCounter_.Counter) != 0);
- }
-
-private:
- TExternalCounter& ExternalCounter_;
-};
-
-void TPointerTest::TestIntrusiveConstConstruction() {
- {
- TRefCountedWithStatistics::TExternalCounter cnt;
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 0);
- TIntrusivePtr<TRefCountedWithStatistics> i{MakeIntrusive<TRefCountedWithStatistics>(cnt)};
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
- i.Reset();
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
- }
- {
- TRefCountedWithStatistics::TExternalCounter cnt;
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 0);
- TIntrusiveConstPtr<TRefCountedWithStatistics> c{MakeIntrusive<TRefCountedWithStatistics>(cnt)};
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
- c.Reset();
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
- }
-}
+
+class TRefCountedWithStatistics: public TNonCopyable {
+public:
+ struct TExternalCounter {
+ TAtomic Counter{0};
+ TAtomic Increments{0};
+ };
+
+ TRefCountedWithStatistics(TExternalCounter& cnt)
+ : ExternalCounter_(cnt)
+ {
+ ExternalCounter_ = {}; // reset counters
+ }
+
+ void Ref() noexcept {
+ AtomicIncrement(ExternalCounter_.Counter);
+ AtomicIncrement(ExternalCounter_.Increments);
+ }
+
+ void UnRef() noexcept {
+ if (AtomicDecrement(ExternalCounter_.Counter) == 0) {
+ TDelete::Destroy(this);
+ }
+ }
+
+ void DecRef() noexcept {
+ Y_VERIFY(AtomicDecrement(ExternalCounter_.Counter) != 0);
+ }
+
+private:
+ TExternalCounter& ExternalCounter_;
+};
+
+void TPointerTest::TestIntrusiveConstConstruction() {
+ {
+ TRefCountedWithStatistics::TExternalCounter cnt;
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 0);
+ TIntrusivePtr<TRefCountedWithStatistics> i{MakeIntrusive<TRefCountedWithStatistics>(cnt)};
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
+ i.Reset();
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
+ }
+ {
+ TRefCountedWithStatistics::TExternalCounter cnt;
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 0);
+ TIntrusiveConstPtr<TRefCountedWithStatistics> c{MakeIntrusive<TRefCountedWithStatistics>(cnt)};
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
+ c.Reset();
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Counter), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(cnt.Increments), 1);
+ }
+}
diff --git a/util/generic/scope.h b/util/generic/scope.h
index 394c8af6be..b2c33af61e 100644
--- a/util/generic/scope.h
+++ b/util/generic/scope.h
@@ -43,15 +43,15 @@ namespace NPrivate {
// General implementaion of RAII idiom (resource acquisition is initialization). Executes
// function upon return from the current scope.
//
-// @note expects `body` to provide no-throw guarantee, otherwise whenever an exception
-// is thrown and leaves the outermost block of `body`, the function `std::terminate` is called.
+// @note expects `body` to provide no-throw guarantee, otherwise whenever an exception
+// is thrown and leaves the outermost block of `body`, the function `std::terminate` is called.
// @see http://drdobbs.com/184403758 for detailed motivation.
#define Y_SCOPE_EXIT(...) const auto Y_GENERATE_UNIQUE_ID(scopeGuard) Y_DECLARE_UNUSED = ::NPrivate::TMakeGuardHelper{} | [__VA_ARGS__]() mutable -> void
// \brief `Y_DEFER { body };`
//
// Same as `Y_SCOPE_EXIT` but doesn't require user to provide capture-list explicitly (it
-// implicitly uses `[&]` capture). Have same requirements for `body`.
+// implicitly uses `[&]` capture). Have same requirements for `body`.
//
// Inspired by `defer` statement in languages like Swift and Go.
//
diff --git a/util/generic/serialized_enum.cpp b/util/generic/serialized_enum.cpp
index f4c2a2ecef..1478c50b22 100644
--- a/util/generic/serialized_enum.cpp
+++ b/util/generic/serialized_enum.cpp
@@ -1 +1 @@
-#include "serialized_enum.h"
+#include "serialized_enum.h"
diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h
index 1cf78499bf..79df2bac22 100644
--- a/util/generic/serialized_enum.h
+++ b/util/generic/serialized_enum.h
@@ -1,20 +1,20 @@
#pragma once
#include <util/generic/fwd.h>
-#include <util/generic/vector.h>
-#include <util/generic/map.h>
+#include <util/generic/vector.h>
+#include <util/generic/map.h>
#include <cstddef>
-#include <type_traits>
+#include <type_traits>
/*
-A file with declarations of enumeration-related functions.
-It doesn't contains definitions. To generate them you have to add
+A file with declarations of enumeration-related functions.
+It doesn't contains definitions. To generate them you have to add
GENERATE_ENUM_SERIALIZATION_WITH_HEADER(your_header_with_your_enum.h)
-or
- GENERATE_ENUM_SERIALIZATION(your_header_with_your_enum.h)
+or
+ GENERATE_ENUM_SERIALIZATION(your_header_with_your_enum.h)
in your ya.make
@@ -31,58 +31,58 @@ in your ya.make
template <typename EnumT>
Y_CONST_FUNCTION constexpr size_t GetEnumItemsCount();
-namespace NEnumSerializationRuntime {
- namespace NDetail {
- template <typename EEnum>
- struct TSelectEnumRepresentationType;
-
- template <typename TEnumType, typename TRepresentationType, class TStorage = TVector<TRepresentationType>>
- class TMappedArrayView;
-
- template <typename TEnumType, typename TRepresentationType, typename TValueType, class TStorage = TMap<TRepresentationType, TValueType>>
- class TMappedDictView;
- }
-
- /// Class with behaviour similar to TMap<EnumT, TValueType>
- template <typename EnumT, typename TValueType>
- using TMappedDictView = NDetail::TMappedDictView<EnumT, typename NDetail::TSelectEnumRepresentationType<EnumT>::TType, TValueType>;
-
- /// Class with behaviour similar to TVector<EnumT>
- template <typename EnumT>
- using TMappedArrayView = NDetail::TMappedArrayView<EnumT, typename NDetail::TSelectEnumRepresentationType<EnumT>::TType>;
-
- /**
- * Returns names for items in enum or enum class
- *
- * @tparam EnumT enum type
- */
- template <typename EnumT>
- TMappedDictView<EnumT, TString> GetEnumNamesImpl();
- /**
- * Returns unique items in enum or enum class
- *
- * @tparam EnumT enum type
- */
- template <typename EnumT>
- ::NEnumSerializationRuntime::TMappedArrayView<EnumT> GetEnumAllValuesImpl();
-
- /**
- * Returns human-readable comma-separated list of names in enum or enum class
- *
- * @tparam EnumT enum type
- */
- template <typename EnumT>
- const TString& GetEnumAllNamesImpl();
-
- /**
- * Returns C++ identifiers for items in enum or enum class
- *
- * @tparam EnumT enum type
- */
- template <typename EnumT>
- const TVector<TString>& GetEnumAllCppNamesImpl();
-}
-
+namespace NEnumSerializationRuntime {
+ namespace NDetail {
+ template <typename EEnum>
+ struct TSelectEnumRepresentationType;
+
+ template <typename TEnumType, typename TRepresentationType, class TStorage = TVector<TRepresentationType>>
+ class TMappedArrayView;
+
+ template <typename TEnumType, typename TRepresentationType, typename TValueType, class TStorage = TMap<TRepresentationType, TValueType>>
+ class TMappedDictView;
+ }
+
+ /// Class with behaviour similar to TMap<EnumT, TValueType>
+ template <typename EnumT, typename TValueType>
+ using TMappedDictView = NDetail::TMappedDictView<EnumT, typename NDetail::TSelectEnumRepresentationType<EnumT>::TType, TValueType>;
+
+ /// Class with behaviour similar to TVector<EnumT>
+ template <typename EnumT>
+ using TMappedArrayView = NDetail::TMappedArrayView<EnumT, typename NDetail::TSelectEnumRepresentationType<EnumT>::TType>;
+
+ /**
+ * Returns names for items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+ template <typename EnumT>
+ TMappedDictView<EnumT, TString> GetEnumNamesImpl();
+ /**
+ * Returns unique items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+ template <typename EnumT>
+ ::NEnumSerializationRuntime::TMappedArrayView<EnumT> GetEnumAllValuesImpl();
+
+ /**
+ * Returns human-readable comma-separated list of names in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+ template <typename EnumT>
+ const TString& GetEnumAllNamesImpl();
+
+ /**
+ * Returns C++ identifiers for items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+ template <typename EnumT>
+ const TVector<TString>& GetEnumAllCppNamesImpl();
+}
+
/**
* Returns names for items in enum or enum class
*
@@ -90,310 +90,310 @@ namespace NEnumSerializationRuntime {
*/
template <typename EnumT>
Y_CONST_FUNCTION ::NEnumSerializationRuntime::TMappedDictView<EnumT, TString> GetEnumNames() {
- return ::NEnumSerializationRuntime::GetEnumNamesImpl<EnumT>();
-}
-
-/**
- * Returns unique items in enum or enum class
- *
- * @tparam EnumT enum type
- */
-template <typename EnumT>
+ return ::NEnumSerializationRuntime::GetEnumNamesImpl<EnumT>();
+}
+
+/**
+ * Returns unique items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+template <typename EnumT>
Y_CONST_FUNCTION ::NEnumSerializationRuntime::TMappedArrayView<EnumT> GetEnumAllValues() {
- return ::NEnumSerializationRuntime::GetEnumAllValuesImpl<EnumT>();
-}
-
-/**
- * Returns human-readable comma-separated list of names in enum or enum class
- *
- * @tparam EnumT enum type
- */
-template <typename EnumT>
+ return ::NEnumSerializationRuntime::GetEnumAllValuesImpl<EnumT>();
+}
+
+/**
+ * Returns human-readable comma-separated list of names in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+template <typename EnumT>
Y_CONST_FUNCTION const TString& GetEnumAllNames() {
- return ::NEnumSerializationRuntime::GetEnumAllNamesImpl<EnumT>();
-}
-
-/**
- * Returns C++ identifiers for items in enum or enum class
- *
- * @tparam EnumT enum type
- */
-template <typename EnumT>
+ return ::NEnumSerializationRuntime::GetEnumAllNamesImpl<EnumT>();
+}
+
+/**
+ * Returns C++ identifiers for items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+template <typename EnumT>
Y_CONST_FUNCTION const TVector<TString>& GetEnumAllCppNames() {
- return ::NEnumSerializationRuntime::GetEnumAllCppNamesImpl<EnumT>();
-}
-
-namespace NEnumSerializationRuntime {
- namespace NDetail {
- /// Checks that the `From` type can be promoted up to the `To` type without losses
- template <typename From, typename To>
- struct TIsPromotable: public std::is_same<std::common_type_t<From, To>, To> {
- static_assert(std::is_integral<From>::value, "`From` type has to be an integer");
- static_assert(std::is_integral<To>::value, "`To` type has to be an integer");
- };
-
- /// Selects enum representation type. Works like std::underlying_type_t<>, but promotes small types up to `int`
- template <typename EEnum>
- struct TSelectEnumRepresentationType {
- using TUnderlyingType = std::underlying_type_t<EEnum>;
- using TIsSigned = std::is_signed<TUnderlyingType>;
- using TRepresentationType = std::conditional_t<
- TIsSigned::value,
- std::conditional_t<
- TIsPromotable<TUnderlyingType, int>::value,
- int,
- long long>,
- std::conditional_t<
- TIsPromotable<TUnderlyingType, unsigned>::value,
- unsigned,
- unsigned long long>>;
- using TType = TRepresentationType;
- static_assert(sizeof(TUnderlyingType) <= sizeof(TType), "size of `TType` is not smaller than the size of `TUnderlyingType`");
- };
-
- template <typename TEnumType, typename TRepresentationType>
- class TMappedViewBase {
- static_assert(sizeof(std::underlying_type_t<TEnumType>) <= sizeof(TRepresentationType), "Internal type is probably too small to represent all possible values");
-
- public:
- static constexpr TEnumType CastFromRepresentationType(const TRepresentationType key) noexcept {
- return static_cast<TEnumType>(key);
- }
-
- static constexpr TRepresentationType CastToRepresentationType(const TEnumType key) noexcept {
- return static_cast<TRepresentationType>(key);
- }
- };
-
- /// Wrapper class with behaviour similar to TVector<EnumT>
- ///
- /// @tparam TEnumType enum type at the external interface
- /// @tparam TRepresentationType designated underlying type of enum
- /// @tparam TStorage internal container type
- template <typename TEnumType, typename TRepresentationType, class TStorage>
- class TMappedArrayView: public TMappedViewBase<TEnumType, TRepresentationType> {
- public:
- using value_type = TEnumType;
-
- public:
- TMappedArrayView(const TStorage& a) noexcept
- : Ref(a)
- {
- }
-
- class TIterator {
- public:
- using TSlaveIteratorType = typename TStorage::const_iterator;
-
- using difference_type = std::ptrdiff_t;
- using value_type = TEnumType;
- using pointer = const TEnumType*;
- using reference = const TEnumType&;
- using iterator_category = std::bidirectional_iterator_tag;
-
- public:
- TIterator(TSlaveIteratorType it)
- : Slave(std::move(it))
- {
- }
-
- bool operator==(const TIterator& it) const {
- return Slave == it.Slave;
- }
-
- bool operator!=(const TIterator& it) const {
- return !(*this == it);
- }
-
- TEnumType operator*() const {
- return TMappedArrayView::CastFromRepresentationType(*Slave);
- }
-
- TIterator& operator++() {
- ++Slave;
- return *this;
- }
-
- TIterator& operator--() {
- --Slave;
- return *this;
- }
-
- TIterator operator++(int) {
- auto temp = Slave;
- ++Slave;
- return temp;
- }
-
- TIterator operator--(int) {
- auto temp = Slave;
- --Slave;
- return temp;
- }
-
- private:
- TSlaveIteratorType Slave;
- };
-
- TIterator begin() const {
- return Ref.begin();
- }
-
- TIterator end() const {
- return Ref.end();
- }
-
- size_t size() const {
- return Ref.size();
- }
-
+ return ::NEnumSerializationRuntime::GetEnumAllCppNamesImpl<EnumT>();
+}
+
+namespace NEnumSerializationRuntime {
+ namespace NDetail {
+ /// Checks that the `From` type can be promoted up to the `To` type without losses
+ template <typename From, typename To>
+ struct TIsPromotable: public std::is_same<std::common_type_t<From, To>, To> {
+ static_assert(std::is_integral<From>::value, "`From` type has to be an integer");
+ static_assert(std::is_integral<To>::value, "`To` type has to be an integer");
+ };
+
+ /// Selects enum representation type. Works like std::underlying_type_t<>, but promotes small types up to `int`
+ template <typename EEnum>
+ struct TSelectEnumRepresentationType {
+ using TUnderlyingType = std::underlying_type_t<EEnum>;
+ using TIsSigned = std::is_signed<TUnderlyingType>;
+ using TRepresentationType = std::conditional_t<
+ TIsSigned::value,
+ std::conditional_t<
+ TIsPromotable<TUnderlyingType, int>::value,
+ int,
+ long long>,
+ std::conditional_t<
+ TIsPromotable<TUnderlyingType, unsigned>::value,
+ unsigned,
+ unsigned long long>>;
+ using TType = TRepresentationType;
+ static_assert(sizeof(TUnderlyingType) <= sizeof(TType), "size of `TType` is not smaller than the size of `TUnderlyingType`");
+ };
+
+ template <typename TEnumType, typename TRepresentationType>
+ class TMappedViewBase {
+ static_assert(sizeof(std::underlying_type_t<TEnumType>) <= sizeof(TRepresentationType), "Internal type is probably too small to represent all possible values");
+
+ public:
+ static constexpr TEnumType CastFromRepresentationType(const TRepresentationType key) noexcept {
+ return static_cast<TEnumType>(key);
+ }
+
+ static constexpr TRepresentationType CastToRepresentationType(const TEnumType key) noexcept {
+ return static_cast<TRepresentationType>(key);
+ }
+ };
+
+ /// Wrapper class with behaviour similar to TVector<EnumT>
+ ///
+ /// @tparam TEnumType enum type at the external interface
+ /// @tparam TRepresentationType designated underlying type of enum
+ /// @tparam TStorage internal container type
+ template <typename TEnumType, typename TRepresentationType, class TStorage>
+ class TMappedArrayView: public TMappedViewBase<TEnumType, TRepresentationType> {
+ public:
+ using value_type = TEnumType;
+
+ public:
+ TMappedArrayView(const TStorage& a) noexcept
+ : Ref(a)
+ {
+ }
+
+ class TIterator {
+ public:
+ using TSlaveIteratorType = typename TStorage::const_iterator;
+
+ using difference_type = std::ptrdiff_t;
+ using value_type = TEnumType;
+ using pointer = const TEnumType*;
+ using reference = const TEnumType&;
+ using iterator_category = std::bidirectional_iterator_tag;
+
+ public:
+ TIterator(TSlaveIteratorType it)
+ : Slave(std::move(it))
+ {
+ }
+
+ bool operator==(const TIterator& it) const {
+ return Slave == it.Slave;
+ }
+
+ bool operator!=(const TIterator& it) const {
+ return !(*this == it);
+ }
+
+ TEnumType operator*() const {
+ return TMappedArrayView::CastFromRepresentationType(*Slave);
+ }
+
+ TIterator& operator++() {
+ ++Slave;
+ return *this;
+ }
+
+ TIterator& operator--() {
+ --Slave;
+ return *this;
+ }
+
+ TIterator operator++(int) {
+ auto temp = Slave;
+ ++Slave;
+ return temp;
+ }
+
+ TIterator operator--(int) {
+ auto temp = Slave;
+ --Slave;
+ return temp;
+ }
+
+ private:
+ TSlaveIteratorType Slave;
+ };
+
+ TIterator begin() const {
+ return Ref.begin();
+ }
+
+ TIterator end() const {
+ return Ref.end();
+ }
+
+ size_t size() const {
+ return Ref.size();
+ }
+
Y_PURE_FUNCTION bool empty() const {
- return Ref.empty();
- }
-
- TEnumType at(size_t index) const {
- return this->CastFromRepresentationType(Ref.at(index));
- }
-
- TEnumType operator[](size_t index) const {
- return this->CastFromRepresentationType(Ref[index]);
- }
-
- // Allocate container and copy view's content into it
- template <template <class...> class TContainer = TVector>
- TContainer<TEnumType> Materialize() const {
- return {begin(), end()};
- }
-
- private:
- const TStorage& Ref;
- };
-
- /// Wrapper class with behaviour similar to TMap<EnumT, TValueType>
- ///
- /// @tparam TEnumType enum type at the external interface
- /// @tparam TRepresentationType designated underlying type of enum
- /// @tparam TValueType mapped value
- /// @tparam TStorage internal container type
- template <typename TEnumType, typename TRepresentationType, typename TValueType, class TStorage>
- class TMappedDictView: public TMappedViewBase<TEnumType, TRepresentationType> {
- public:
- using TMappedItemType = std::pair<const TEnumType, const TValueType&>;
-
- class TDereferenceResultHolder {
- public:
- TDereferenceResultHolder(const TRepresentationType enumValue, const TValueType& payload) noexcept
- : Data(TMappedDictView::CastFromRepresentationType(enumValue), payload)
- {
- }
-
- const TMappedItemType* operator->() const noexcept {
- return &Data;
- }
-
- private:
- TMappedItemType Data;
- };
-
- TMappedDictView(const TStorage& m) noexcept
- : Ref(m)
- {
- }
-
- class TIterator {
- public:
- using TSlaveIteratorType = typename TStorage::const_iterator;
-
- using difference_type = std::ptrdiff_t;
- using value_type = TMappedItemType;
- using pointer = const TMappedItemType*;
- using reference = const TMappedItemType&;
- using iterator_category = std::bidirectional_iterator_tag;
-
- public:
- TIterator(TSlaveIteratorType it)
- : Slave(std::move(it))
- {
- }
-
- bool operator==(const TIterator& it) const {
- return Slave == it.Slave;
- }
-
- bool operator!=(const TIterator& it) const {
- return !(*this == it);
- }
-
- TDereferenceResultHolder operator->() const {
- return {Slave->first, Slave->second};
- }
-
- TMappedItemType operator*() const {
- return {TMappedDictView::CastFromRepresentationType(Slave->first), Slave->second};
- }
-
- TIterator& operator++() {
- ++Slave;
- return *this;
- }
-
- TIterator& operator--() {
- --Slave;
- return *this;
- }
-
- TIterator operator++(int) {
- auto temp = Slave;
- ++Slave;
- return temp;
- }
-
- TIterator operator--(int) {
- auto temp = Slave;
- --Slave;
- return temp;
- }
-
- private:
- TSlaveIteratorType Slave;
- };
-
- TIterator begin() const {
- return Ref.begin();
- }
-
- TIterator end() const {
- return Ref.end();
- }
-
- size_t size() const {
- return Ref.size();
- }
-
+ return Ref.empty();
+ }
+
+ TEnumType at(size_t index) const {
+ return this->CastFromRepresentationType(Ref.at(index));
+ }
+
+ TEnumType operator[](size_t index) const {
+ return this->CastFromRepresentationType(Ref[index]);
+ }
+
+ // Allocate container and copy view's content into it
+ template <template <class...> class TContainer = TVector>
+ TContainer<TEnumType> Materialize() const {
+ return {begin(), end()};
+ }
+
+ private:
+ const TStorage& Ref;
+ };
+
+ /// Wrapper class with behaviour similar to TMap<EnumT, TValueType>
+ ///
+ /// @tparam TEnumType enum type at the external interface
+ /// @tparam TRepresentationType designated underlying type of enum
+ /// @tparam TValueType mapped value
+ /// @tparam TStorage internal container type
+ template <typename TEnumType, typename TRepresentationType, typename TValueType, class TStorage>
+ class TMappedDictView: public TMappedViewBase<TEnumType, TRepresentationType> {
+ public:
+ using TMappedItemType = std::pair<const TEnumType, const TValueType&>;
+
+ class TDereferenceResultHolder {
+ public:
+ TDereferenceResultHolder(const TRepresentationType enumValue, const TValueType& payload) noexcept
+ : Data(TMappedDictView::CastFromRepresentationType(enumValue), payload)
+ {
+ }
+
+ const TMappedItemType* operator->() const noexcept {
+ return &Data;
+ }
+
+ private:
+ TMappedItemType Data;
+ };
+
+ TMappedDictView(const TStorage& m) noexcept
+ : Ref(m)
+ {
+ }
+
+ class TIterator {
+ public:
+ using TSlaveIteratorType = typename TStorage::const_iterator;
+
+ using difference_type = std::ptrdiff_t;
+ using value_type = TMappedItemType;
+ using pointer = const TMappedItemType*;
+ using reference = const TMappedItemType&;
+ using iterator_category = std::bidirectional_iterator_tag;
+
+ public:
+ TIterator(TSlaveIteratorType it)
+ : Slave(std::move(it))
+ {
+ }
+
+ bool operator==(const TIterator& it) const {
+ return Slave == it.Slave;
+ }
+
+ bool operator!=(const TIterator& it) const {
+ return !(*this == it);
+ }
+
+ TDereferenceResultHolder operator->() const {
+ return {Slave->first, Slave->second};
+ }
+
+ TMappedItemType operator*() const {
+ return {TMappedDictView::CastFromRepresentationType(Slave->first), Slave->second};
+ }
+
+ TIterator& operator++() {
+ ++Slave;
+ return *this;
+ }
+
+ TIterator& operator--() {
+ --Slave;
+ return *this;
+ }
+
+ TIterator operator++(int) {
+ auto temp = Slave;
+ ++Slave;
+ return temp;
+ }
+
+ TIterator operator--(int) {
+ auto temp = Slave;
+ --Slave;
+ return temp;
+ }
+
+ private:
+ TSlaveIteratorType Slave;
+ };
+
+ TIterator begin() const {
+ return Ref.begin();
+ }
+
+ TIterator end() const {
+ return Ref.end();
+ }
+
+ size_t size() const {
+ return Ref.size();
+ }
+
Y_PURE_FUNCTION bool empty() const {
- return Ref.empty();
- }
-
- bool contains(const TEnumType key) const {
+ return Ref.empty();
+ }
+
+ bool contains(const TEnumType key) const {
return Ref.contains(this->CastToRepresentationType(key));
- }
-
- TIterator find(const TEnumType key) const {
- return Ref.find(this->CastToRepresentationType(key));
- }
-
- const TValueType& at(const TEnumType key) const {
- return Ref.at(this->CastToRepresentationType(key));
- }
-
- // Allocate container and copy view's content into it
- template <template <class...> class TContainer = TMap>
- TContainer<TEnumType, TValueType> Materialize() const {
- return {begin(), end()};
- }
-
- private:
- const TStorage& Ref;
- };
- }
-}
+ }
+
+ TIterator find(const TEnumType key) const {
+ return Ref.find(this->CastToRepresentationType(key));
+ }
+
+ const TValueType& at(const TEnumType key) const {
+ return Ref.at(this->CastToRepresentationType(key));
+ }
+
+ // Allocate container and copy view's content into it
+ template <template <class...> class TContainer = TMap>
+ TContainer<TEnumType, TValueType> Materialize() const {
+ return {begin(), end()};
+ }
+
+ private:
+ const TStorage& Ref;
+ };
+ }
+}
diff --git a/util/generic/serialized_enum_ut.cpp b/util/generic/serialized_enum_ut.cpp
index 0c1b276a38..3a94e1d471 100644
--- a/util/generic/serialized_enum_ut.cpp
+++ b/util/generic/serialized_enum_ut.cpp
@@ -1,120 +1,120 @@
-#include "serialized_enum.h"
-
+#include "serialized_enum.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/deque.h>
-#include <util/generic/map.h>
-#include <util/generic/typelist.h>
-#include <util/generic/vector.h>
-
-Y_UNIT_TEST_SUITE(TestSerializedEnum) {
- Y_UNIT_TEST(RepresentationTypes) {
- using namespace NEnumSerializationRuntime::NDetail;
-
- static_assert(TIsPromotable<int, int>::value, "int -> int");
- static_assert(TIsPromotable<char, int>::value, "char -> int");
- static_assert(TIsPromotable<unsigned short, unsigned long>::value, "unsigned short -> unsigned long");
- static_assert(TIsPromotable<i64, long long>::value, "i64 -> long long");
- static_assert(!TIsPromotable<ui64, ui8>::value, "ui64 -> ui8");
- static_assert(!TIsPromotable<i64, short>::value, "i64 -> short");
-
- enum EEmpty {
- };
+
+#include <util/generic/deque.h>
+#include <util/generic/map.h>
+#include <util/generic/typelist.h>
+#include <util/generic/vector.h>
+
+Y_UNIT_TEST_SUITE(TestSerializedEnum) {
+ Y_UNIT_TEST(RepresentationTypes) {
+ using namespace NEnumSerializationRuntime::NDetail;
+
+ static_assert(TIsPromotable<int, int>::value, "int -> int");
+ static_assert(TIsPromotable<char, int>::value, "char -> int");
+ static_assert(TIsPromotable<unsigned short, unsigned long>::value, "unsigned short -> unsigned long");
+ static_assert(TIsPromotable<i64, long long>::value, "i64 -> long long");
+ static_assert(!TIsPromotable<ui64, ui8>::value, "ui64 -> ui8");
+ static_assert(!TIsPromotable<i64, short>::value, "i64 -> short");
+
+ enum EEmpty {
+ };
UNIT_ASSERT_C((TTypeList<int, unsigned>::THave<typename TSelectEnumRepresentationType<EEmpty>::TType>::value), "empty enum using signed or unsigned integer underlying type");
-
- using TRepresentationTypeList = TTypeList<int, unsigned, long long, unsigned long long>;
-
- enum class ERegular {
- One = 1,
- Two = 2,
- Five = 5,
- };
+
+ using TRepresentationTypeList = TTypeList<int, unsigned, long long, unsigned long long>;
+
+ enum class ERegular {
+ One = 1,
+ Two = 2,
+ Five = 5,
+ };
UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ERegular>::TType>::value);
-
+
enum class ESmall: unsigned char {
- Six = 6,
- };
+ Six = 6,
+ };
UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ESmall>::TType>::value);
-
+
enum class EHugeUnsigned: ui64 {
- Value = 0,
- };
+ Value = 0,
+ };
UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeUnsigned>::TType>::value);
-
+
enum class EHugeSigned: i64 {
- Value = -2,
- };
+ Value = -2,
+ };
UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeSigned>::TType>::value);
- }
-
- Y_UNIT_TEST(MappedArrayView) {
+ }
+
+ Y_UNIT_TEST(MappedArrayView) {
enum class ETestEnum: signed char {
- Zero = 0,
- One = 1,
- Two = 2,
- Three = 3,
- Four = 4,
- Eleven = 11,
- };
- const TVector<int> values = {1, 2, 3, 0, 0, 0, 11, 0, 0, 0, 0, 0, 2};
- const auto view = ::NEnumSerializationRuntime::TMappedArrayView<ETestEnum>{values};
-
- UNIT_ASSERT_VALUES_EQUAL(view.size(), values.size());
- UNIT_ASSERT_VALUES_EQUAL(view.empty(), false);
- UNIT_ASSERT_EQUAL(*view.begin(), ETestEnum::One);
- UNIT_ASSERT_EQUAL(view[6], ETestEnum::Eleven);
- UNIT_ASSERT_EXCEPTION(view.at(-1), std::out_of_range);
- UNIT_ASSERT_VALUES_EQUAL(sizeof(view[4]), sizeof(signed char));
- UNIT_ASSERT_VALUES_EQUAL(sizeof(values[4]), sizeof(int));
- for (const ETestEnum e : view) {
- UNIT_ASSERT_UNEQUAL(e, ETestEnum::Four);
- }
-
- const TVector<ETestEnum> typedValues = {ETestEnum::One, ETestEnum::Two, ETestEnum::Three, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Eleven, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Two};
- UNIT_ASSERT_EQUAL(typedValues, view.Materialize());
-
- const TDeque<ETestEnum> typedValuesDeque{typedValues.begin(), typedValues.end()};
- UNIT_ASSERT_EQUAL(typedValuesDeque, view.Materialize<TDeque>());
- }
-
- Y_UNIT_TEST(MappedDictView) {
+ Zero = 0,
+ One = 1,
+ Two = 2,
+ Three = 3,
+ Four = 4,
+ Eleven = 11,
+ };
+ const TVector<int> values = {1, 2, 3, 0, 0, 0, 11, 0, 0, 0, 0, 0, 2};
+ const auto view = ::NEnumSerializationRuntime::TMappedArrayView<ETestEnum>{values};
+
+ UNIT_ASSERT_VALUES_EQUAL(view.size(), values.size());
+ UNIT_ASSERT_VALUES_EQUAL(view.empty(), false);
+ UNIT_ASSERT_EQUAL(*view.begin(), ETestEnum::One);
+ UNIT_ASSERT_EQUAL(view[6], ETestEnum::Eleven);
+ UNIT_ASSERT_EXCEPTION(view.at(-1), std::out_of_range);
+ UNIT_ASSERT_VALUES_EQUAL(sizeof(view[4]), sizeof(signed char));
+ UNIT_ASSERT_VALUES_EQUAL(sizeof(values[4]), sizeof(int));
+ for (const ETestEnum e : view) {
+ UNIT_ASSERT_UNEQUAL(e, ETestEnum::Four);
+ }
+
+ const TVector<ETestEnum> typedValues = {ETestEnum::One, ETestEnum::Two, ETestEnum::Three, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Eleven, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Two};
+ UNIT_ASSERT_EQUAL(typedValues, view.Materialize());
+
+ const TDeque<ETestEnum> typedValuesDeque{typedValues.begin(), typedValues.end()};
+ UNIT_ASSERT_EQUAL(typedValuesDeque, view.Materialize<TDeque>());
+ }
+
+ Y_UNIT_TEST(MappedDictView) {
enum class ETestEnum: unsigned short {
- Zero = 0,
- One = 1,
- Two = 2,
- Three = 3,
- Four = 4,
- Eleven = 11,
- Fake = (unsigned short)(-1),
- };
- const TMap<unsigned, unsigned> map = {{0, 1}, {1, 2}, {2, 4}, {3, 8}, {4, 16}, {11, 2048}};
- const auto view = ::NEnumSerializationRuntime::NDetail::TMappedDictView<ETestEnum, unsigned, unsigned, decltype(map)>{map};
-
- UNIT_ASSERT_VALUES_EQUAL(view.size(), map.size());
- UNIT_ASSERT_VALUES_EQUAL(map.empty(), false);
-
- UNIT_ASSERT_EQUAL(view.begin()->first, ETestEnum::Zero);
- UNIT_ASSERT_VALUES_EQUAL(view.begin()->second, 1u);
-
- UNIT_ASSERT_VALUES_EQUAL(view.contains(ETestEnum::Fake), false);
- UNIT_ASSERT_VALUES_EQUAL(view.contains(ETestEnum::Four), true);
-
- UNIT_ASSERT_EXCEPTION(view.at(ETestEnum::Fake), std::out_of_range);
- UNIT_ASSERT_NO_EXCEPTION(view.at(ETestEnum::Eleven));
-
- UNIT_ASSERT_VALUES_EQUAL(view.at(ETestEnum::Three), 8u);
-
- unsigned mask = 0;
- unsigned sum = 0;
- for (const auto e : view) {
- mask |= e.second;
- sum += e.second;
- }
- UNIT_ASSERT_VALUES_EQUAL(mask, 2079);
- UNIT_ASSERT_VALUES_EQUAL(sum, 2079);
-
- const TMap<ETestEnum, unsigned> materialized = view.Materialize<TMap>();
- UNIT_ASSERT_VALUES_EQUAL(materialized.size(), map.size());
- UNIT_ASSERT_VALUES_EQUAL(materialized.at(ETestEnum::Four), 16);
- }
-}
+ Zero = 0,
+ One = 1,
+ Two = 2,
+ Three = 3,
+ Four = 4,
+ Eleven = 11,
+ Fake = (unsigned short)(-1),
+ };
+ const TMap<unsigned, unsigned> map = {{0, 1}, {1, 2}, {2, 4}, {3, 8}, {4, 16}, {11, 2048}};
+ const auto view = ::NEnumSerializationRuntime::NDetail::TMappedDictView<ETestEnum, unsigned, unsigned, decltype(map)>{map};
+
+ UNIT_ASSERT_VALUES_EQUAL(view.size(), map.size());
+ UNIT_ASSERT_VALUES_EQUAL(map.empty(), false);
+
+ UNIT_ASSERT_EQUAL(view.begin()->first, ETestEnum::Zero);
+ UNIT_ASSERT_VALUES_EQUAL(view.begin()->second, 1u);
+
+ UNIT_ASSERT_VALUES_EQUAL(view.contains(ETestEnum::Fake), false);
+ UNIT_ASSERT_VALUES_EQUAL(view.contains(ETestEnum::Four), true);
+
+ UNIT_ASSERT_EXCEPTION(view.at(ETestEnum::Fake), std::out_of_range);
+ UNIT_ASSERT_NO_EXCEPTION(view.at(ETestEnum::Eleven));
+
+ UNIT_ASSERT_VALUES_EQUAL(view.at(ETestEnum::Three), 8u);
+
+ unsigned mask = 0;
+ unsigned sum = 0;
+ for (const auto e : view) {
+ mask |= e.second;
+ sum += e.second;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(mask, 2079);
+ UNIT_ASSERT_VALUES_EQUAL(sum, 2079);
+
+ const TMap<ETestEnum, unsigned> materialized = view.Materialize<TMap>();
+ UNIT_ASSERT_VALUES_EQUAL(materialized.size(), map.size());
+ UNIT_ASSERT_VALUES_EQUAL(materialized.at(ETestEnum::Four), 16);
+ }
+}
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index fa4ea1f57e..69cde785af 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -20,11 +20,11 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
std::string_view helloWorld("Hello, World!");
TStringBuf fromStringView(helloWorld);
UNIT_ASSERT_EQUAL(fromStringView.data(), helloWorld.data());
- UNIT_ASSERT_EQUAL(fromStringView.size(), helloWorld.size());
+ UNIT_ASSERT_EQUAL(fromStringView.size(), helloWorld.size());
std::string_view fromStringBuf = fromStringView;
UNIT_ASSERT_EQUAL(helloWorld.data(), fromStringBuf.data());
- UNIT_ASSERT_EQUAL(helloWorld.size(), fromStringBuf.size());
+ UNIT_ASSERT_EQUAL(helloWorld.size(), fromStringBuf.size());
}
Y_UNIT_TEST(TestConstExpr) {
@@ -37,16 +37,16 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_VALUES_EQUAL(str1, str2);
UNIT_ASSERT_VALUES_EQUAL(str2, str3);
UNIT_ASSERT_VALUES_EQUAL(str1, str3);
-
- static constexpr std::string_view view1(str1);
- UNIT_ASSERT_VALUES_EQUAL(str1, view1);
- static_assert(str1.data() == view1.data());
- static_assert(str1.size() == view1.size());
-
- static constexpr TStringBuf str4(view1);
- UNIT_ASSERT_VALUES_EQUAL(str1, str4);
- static_assert(str1.data() == str4.data());
- static_assert(str1.size() == str4.size());
+
+ static constexpr std::string_view view1(str1);
+ UNIT_ASSERT_VALUES_EQUAL(str1, view1);
+ static_assert(str1.data() == view1.data());
+ static_assert(str1.size() == view1.size());
+
+ static constexpr TStringBuf str4(view1);
+ UNIT_ASSERT_VALUES_EQUAL(str1, str4);
+ static_assert(str1.data() == str4.data());
+ static_assert(str1.size() == str4.size());
}
Y_UNIT_TEST(TestAfter) {
diff --git a/util/generic/string.h b/util/generic/string.h
index d7ea474d76..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -134,10 +134,10 @@ public:
return *this;
}
- TBasicCharRef& operator=(const TBasicCharRef& other) {
- return this->operator=(static_cast<TChar>(other));
- }
-
+ TBasicCharRef& operator=(const TBasicCharRef& other) {
+ return this->operator=(static_cast<TChar>(other));
+ }
+
/*
* WARN:
* Though references are copyable types according to the standard,
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 906363794d..44bb10bdeb 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -1031,19 +1031,19 @@ public:
UNIT_ASSERT_VALUES_EQUAL(s0[3], (ui8)'\0');
UNIT_ASSERT_VALUES_EQUAL(s1[3], (ui8)'\0');
UNIT_ASSERT_VALUES_EQUAL(s2[3], (ui8)'\0');
-
- /* Assignment one char reference to another results in modification of underlying character */
- {
- const char_type dark_eyed[] = {'d', 'a', 'r', 'k', '-', 'e', 'y', 'e', 'd', 0};
- const char_type red_eared[] = {'r', 'e', 'd', '-', 'e', 'a', 'r', 'e', 'd', 0};
- TStringType s0 = dark_eyed;
- TStringType s1 = TStringType::Uninitialized(s0.size());
- for (size_t i = 0; i < s1.size(); ++i) {
- const size_t j = (3u * (i + 1u) ^ 1u) % s0.size();
- s1[i] = s0[j];
- }
- UNIT_ASSERT_VALUES_EQUAL(s1, red_eared);
- }
+
+ /* Assignment one char reference to another results in modification of underlying character */
+ {
+ const char_type dark_eyed[] = {'d', 'a', 'r', 'k', '-', 'e', 'y', 'e', 'd', 0};
+ const char_type red_eared[] = {'r', 'e', 'd', '-', 'e', 'a', 'r', 'e', 'd', 0};
+ TStringType s0 = dark_eyed;
+ TStringType s1 = TStringType::Uninitialized(s0.size());
+ for (size_t i = 0; i < s1.size(); ++i) {
+ const size_t j = (3u * (i + 1u) ^ 1u) % s0.size();
+ s1[i] = s0[j];
+ }
+ UNIT_ASSERT_VALUES_EQUAL(s1, red_eared);
+ }
}
#endif
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index 202d1c5c6e..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -281,12 +281,12 @@ struct TIsSpecializationOf<T, T<Ts...>>: std::true_type {};
* }
*/
template <typename... T>
-constexpr bool TDependentFalse = false;
+constexpr bool TDependentFalse = false;
// FIXME: neither nvcc10 nor nvcc11 support using auto in this context
#if defined(__NVCC__)
template <size_t Value>
-constexpr bool TValueDependentFalse = false;
+constexpr bool TValueDependentFalse = false;
#else
template <auto... Values>
constexpr bool TValueDependentFalse = false;
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index fe2ee6abe3..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -461,8 +461,8 @@ static_assert(!TIsSpecializationOf<std::pair, std::vector<int>>::value, "");
static_assert(TIsIterable<std::vector<int>>::value, "");
static_assert(!TIsIterable<int>::value, "");
static_assert(TIsIterable<int[42]>::value, "");
-
-// test for TDependentFalse
-static_assert(TDependentFalse<int> == false);
-static_assert(TDependentFalse<TNonPodClass> == false);
-static_assert(TValueDependentFalse<0x1000> == false);
+
+// test for TDependentFalse
+static_assert(TDependentFalse<int> == false);
+static_assert(TDependentFalse<TNonPodClass> == false);
+static_assert(TValueDependentFalse<0x1000> == false);
diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make
index 1e0bedb780..6eaf24cc5f 100644
--- a/util/generic/ut/ya.make
+++ b/util/generic/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
FORK_TESTS()
@@ -35,7 +35,7 @@ SRCS(
generic/overloaded_ut.cpp
generic/ptr_ut.cpp
generic/queue_ut.cpp
- generic/serialized_enum_ut.cpp
+ generic/serialized_enum_ut.cpp
generic/set_ut.cpp
generic/singleton_ut.cpp
generic/size_literals_ut.cpp
diff --git a/util/generic/utility.h b/util/generic/utility.h
index 4be1373a7f..43b98eeafc 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -6,7 +6,7 @@
template <class T>
static constexpr const T& Min(const T& l, const T& r) {
- return r < l ? r : l;
+ return r < l ? r : l;
}
template <typename T, typename... Args>
@@ -16,7 +16,7 @@ static constexpr const T& Min(const T& a, const T& b, const Args&... args) {
template <class T>
static constexpr const T& Max(const T& l, const T& r) {
- return l < r ? r : l;
+ return l < r ? r : l;
}
template <typename T, typename... Args>
diff --git a/util/generic/utility_ut.cpp b/util/generic/utility_ut.cpp
index 1e106c651f..8e9d5afff9 100644
--- a/util/generic/utility_ut.cpp
+++ b/util/generic/utility_ut.cpp
@@ -23,16 +23,16 @@ private:
TTest& operator=(const TTest&);
};
-struct TUnorderedTag {
- TStringBuf Tag;
-};
-
-static bool operator<(const TUnorderedTag, const TUnorderedTag) {
- return false;
-}
-
-static bool operator>(const TUnorderedTag, const TUnorderedTag) = delete;
-
+struct TUnorderedTag {
+ TStringBuf Tag;
+};
+
+static bool operator<(const TUnorderedTag, const TUnorderedTag) {
+ return false;
+}
+
+static bool operator>(const TUnorderedTag, const TUnorderedTag) = delete;
+
Y_UNIT_TEST_SUITE(TUtilityTest) {
Y_UNIT_TEST(TestSwapPrimitive) {
@@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TUtilityTest) {
static_assert(Max(10, 3, 8) == 10, "Max doesn't work");
UNIT_ASSERT_EQUAL(Min(10, 3, 8), 3);
UNIT_ASSERT_EQUAL(Max(3.5, 4.2, 8.1, 99.025, 0.33, 29.0), 99.025);
-
+
UNIT_ASSERT_VALUES_EQUAL(Min(TUnorderedTag{"first"}, TUnorderedTag{"second"}).Tag, "first");
UNIT_ASSERT_VALUES_EQUAL(Max(TUnorderedTag{"first"}, TUnorderedTag{"second"}).Tag, "first");
UNIT_ASSERT_VALUES_EQUAL(Min(TUnorderedTag{"first"}, TUnorderedTag{"second"}, TUnorderedTag{"third"}).Tag, "first");
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 673be2fb20..0f6b4037a0 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -553,9 +553,9 @@ private:
vec.crop(1); // Should not require default constructor
UNIT_ASSERT(vec.size() == 1);
UNIT_ASSERT(vec[0].Val == 42);
- vec.crop(50); // Does nothing if new size is greater than the current size()
- UNIT_ASSERT(vec.size() == 1);
- UNIT_ASSERT(vec[0].Val == 42);
+ vec.crop(50); // Does nothing if new size is greater than the current size()
+ UNIT_ASSERT(vec.size() == 1);
+ UNIT_ASSERT(vec[0].Val == 42);
}
void TestYResize() {
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 4d9c309001..5fc8c82912 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -85,12 +85,12 @@ namespace NPrivate {
return TIterator(Value - b);
}
- template <typename IntType>
- TIterator& operator-=(const IntType& b) noexcept {
- Value -= b;
- return *this;
- }
-
+ template <typename IntType>
+ TIterator& operator-=(const IntType& b) noexcept {
+ Value -= b;
+ return *this;
+ }
+
constexpr bool operator<(const TIterator& b) const noexcept {
return Value < b.Value;
}
@@ -175,31 +175,31 @@ namespace NPrivate {
}
constexpr TDiff operator-(const TIterator& b) const noexcept {
- return (Value_ - b.Value_) / Parent_->Step_;
+ return (Value_ - b.Value_) / Parent_->Step_;
}
template <typename IntType>
constexpr TIterator operator+(const IntType& b) const noexcept {
- return TIterator(*this) += b;
+ return TIterator(*this) += b;
}
template <typename IntType>
TIterator& operator+=(const IntType& b) noexcept {
- Value_ += b * Parent_->Step_;
+ Value_ += b * Parent_->Step_;
return *this;
}
template <typename IntType>
constexpr TIterator operator-(const IntType& b) const noexcept {
- return TIterator(*this) -= b;
+ return TIterator(*this) -= b;
+ }
+
+ template <typename IntType>
+ TIterator& operator-=(const IntType& b) noexcept {
+ Value_ -= b * Parent_->Step_;
+ return *this;
}
- template <typename IntType>
- TIterator& operator-=(const IntType& b) noexcept {
- Value_ -= b * Parent_->Step_;
- return *this;
- }
-
private:
T Value_;
const TSteppedXRange* Parent_;
diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp
index c41d47c9d1..8106da03e7 100644
--- a/util/generic/xrange_ut.cpp
+++ b/util/generic/xrange_ut.cpp
@@ -1,10 +1,10 @@
#include "xrange.h"
#include "algorithm.h"
-#include "maybe.h"
+#include "maybe.h"
#include "vector.h"
#include <library/cpp/testing/unittest/registar.h>
-#include <util/string/builder.h>
+#include <util/string/builder.h>
Y_UNIT_TEST_SUITE(XRange) {
void TestXRangeImpl(size_t begin, size_t end) {
@@ -156,62 +156,62 @@ Y_UNIT_TEST_SUITE(XRange) {
TestEmptyRanges(emptySteppedRanges);
}
-
- template <class TRange>
- static void TestIteratorDifferenceImpl(TRange range, int a, int b, TMaybe<int> step) {
- auto fmtCase = [&]() -> TString { return TStringBuilder() << "xrange(" << a << ", " << b << (step ? ", " + ToString(*step) : TString{}) << ")"; };
- auto begin = std::begin(range);
- auto end = std::end(range);
- auto distance = end - begin;
- UNIT_ASSERT_VALUES_EQUAL_C(range.size(), distance, fmtCase());
- UNIT_ASSERT_EQUAL_C(end, begin + distance, fmtCase());
- }
-
- Y_UNIT_TEST(IteratorDifference) {
- for (int a = -20; a <= 20; ++a) {
- for (int b = -20; b <= 20; ++b) {
- for (int step = -25; step <= 25; ++step) {
- if (step != 0) {
- TestIteratorDifferenceImpl(xrange(a, b, step), a, b, step);
- }
- }
- TestIteratorDifferenceImpl(xrange(a, b), a, b, Nothing());
- }
- }
- }
-
- Y_UNIT_TEST(Advance) {
- {
- auto range = xrange(30, 160, 7);
- auto it = std::begin(range);
- it += 5;
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 5), *it);
- UNIT_ASSERT_VALUES_EQUAL(65, *it);
- it -= 2;
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 3), *it);
- UNIT_ASSERT_VALUES_EQUAL(51, *it);
- std::advance(it, 10);
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 13), *it);
- UNIT_ASSERT_VALUES_EQUAL(121, *it);
- std::advance(it, -5);
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 8), *it);
- UNIT_ASSERT_VALUES_EQUAL(86, *it);
- }
- {
- auto range = xrange(-20, 100);
- auto it = std::begin(range);
- it += 5;
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 5), *it);
- UNIT_ASSERT_VALUES_EQUAL(-15, *it);
- it -= 2;
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 3), *it);
- UNIT_ASSERT_VALUES_EQUAL(-17, *it);
- std::advance(it, 30);
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 33), *it);
- UNIT_ASSERT_VALUES_EQUAL(13, *it);
- std::advance(it, -8);
- UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 25), *it);
- UNIT_ASSERT_VALUES_EQUAL(5, *it);
- }
- }
+
+ template <class TRange>
+ static void TestIteratorDifferenceImpl(TRange range, int a, int b, TMaybe<int> step) {
+ auto fmtCase = [&]() -> TString { return TStringBuilder() << "xrange(" << a << ", " << b << (step ? ", " + ToString(*step) : TString{}) << ")"; };
+ auto begin = std::begin(range);
+ auto end = std::end(range);
+ auto distance = end - begin;
+ UNIT_ASSERT_VALUES_EQUAL_C(range.size(), distance, fmtCase());
+ UNIT_ASSERT_EQUAL_C(end, begin + distance, fmtCase());
+ }
+
+ Y_UNIT_TEST(IteratorDifference) {
+ for (int a = -20; a <= 20; ++a) {
+ for (int b = -20; b <= 20; ++b) {
+ for (int step = -25; step <= 25; ++step) {
+ if (step != 0) {
+ TestIteratorDifferenceImpl(xrange(a, b, step), a, b, step);
+ }
+ }
+ TestIteratorDifferenceImpl(xrange(a, b), a, b, Nothing());
+ }
+ }
+ }
+
+ Y_UNIT_TEST(Advance) {
+ {
+ auto range = xrange(30, 160, 7);
+ auto it = std::begin(range);
+ it += 5;
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 5), *it);
+ UNIT_ASSERT_VALUES_EQUAL(65, *it);
+ it -= 2;
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 3), *it);
+ UNIT_ASSERT_VALUES_EQUAL(51, *it);
+ std::advance(it, 10);
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 13), *it);
+ UNIT_ASSERT_VALUES_EQUAL(121, *it);
+ std::advance(it, -5);
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 8), *it);
+ UNIT_ASSERT_VALUES_EQUAL(86, *it);
+ }
+ {
+ auto range = xrange(-20, 100);
+ auto it = std::begin(range);
+ it += 5;
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 5), *it);
+ UNIT_ASSERT_VALUES_EQUAL(-15, *it);
+ it -= 2;
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 3), *it);
+ UNIT_ASSERT_VALUES_EQUAL(-17, *it);
+ std::advance(it, 30);
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 33), *it);
+ UNIT_ASSERT_VALUES_EQUAL(13, *it);
+ std::advance(it, -8);
+ UNIT_ASSERT_VALUES_EQUAL(*(std::begin(range) + 25), *it);
+ UNIT_ASSERT_VALUES_EQUAL(5, *it);
+ }
+ }
}
diff --git a/util/generic/ya.make b/util/generic/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/generic/ya.make
+++ b/util/generic/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 46dc3de712..2ce6c4369d 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -1,4 +1,4 @@
-#include "bt_exception.h"
+#include "bt_exception.h"
#include "yexception.h"
#include <util/system/backtrace.h>
@@ -112,11 +112,11 @@ void fputs(const std::exception& e, FILE* f) {
message[len] = 0;
fputs(message, f);
}
-
-void ::NPrivate::ThrowYException(const ::NPrivate::TSimpleExceptionMessage& sm) {
- throw sm.Location + yexception() << sm.Message;
-}
-
-void ::NPrivate::ThrowYExceptionWithBacktrace(const ::NPrivate::TSimpleExceptionMessage& sm) {
- throw sm.Location + TWithBackTrace<yexception>() << sm.Message;
-}
+
+void ::NPrivate::ThrowYException(const ::NPrivate::TSimpleExceptionMessage& sm) {
+ throw sm.Location + yexception() << sm.Message;
+}
+
+void ::NPrivate::ThrowYExceptionWithBacktrace(const ::NPrivate::TSimpleExceptionMessage& sm) {
+ throw sm.Location + TWithBackTrace<yexception>() << sm.Message;
+}
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index b7e93c06da..b0c604e8c4 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -1,6 +1,6 @@
#pragma once
-#include "bt_exception.h"
+#include "bt_exception.h"
#include "strbuf.h"
#include "string.h"
#include "utility.h"
@@ -140,18 +140,18 @@ struct TBadCastException: public virtual TBadArgumentException {
#define ythrow throw __LOCATION__ +
-namespace NPrivate {
- /// Encapsulates data for one of the most common case in which
- /// exception message contists of single constant string
- struct TSimpleExceptionMessage {
- TSourceLocation Location;
- TStringBuf Message;
- };
-
+namespace NPrivate {
+ /// Encapsulates data for one of the most common case in which
+ /// exception message contists of single constant string
+ struct TSimpleExceptionMessage {
+ TSourceLocation Location;
+ TStringBuf Message;
+ };
+
[[noreturn]] void ThrowYException(const TSimpleExceptionMessage& sm);
- [[noreturn]] void ThrowYExceptionWithBacktrace(const TSimpleExceptionMessage& sm);
-}
-
+ [[noreturn]] void ThrowYExceptionWithBacktrace(const TSimpleExceptionMessage& sm);
+}
+
void fputs(const std::exception& e, FILE* f = stderr);
TString CurrentExceptionMessage();
@@ -182,24 +182,24 @@ TString FormatExc(const std::exception& exception);
} \
} while (false)
-/// @def Y_ENSURE_SIMPLE
-/// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view.
-/// Should not be used directly.
-#define Y_ENSURE_SIMPLE(CONDITION, MESSAGE, THROW_FUNCTION) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
- /* use variable to guarantee evaluation at compile time */ \
- static constexpr const ::NPrivate::TSimpleExceptionMessage __SIMPLE_EXCEPTION_MESSAGE{__LOCATION__, (MESSAGE)}; \
- THROW_FUNCTION(__SIMPLE_EXCEPTION_MESSAGE); \
- } \
- } while (false)
-
+/// @def Y_ENSURE_SIMPLE
+/// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view.
+/// Should not be used directly.
+#define Y_ENSURE_SIMPLE(CONDITION, MESSAGE, THROW_FUNCTION) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
+ /* use variable to guarantee evaluation at compile time */ \
+ static constexpr const ::NPrivate::TSimpleExceptionMessage __SIMPLE_EXCEPTION_MESSAGE{__LOCATION__, (MESSAGE)}; \
+ THROW_FUNCTION(__SIMPLE_EXCEPTION_MESSAGE); \
+ } \
+ } while (false)
+
#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException)
#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE)
#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace)
-#define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE)
-
+#define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE)
+
/**
* @def Y_ENSURE
*
@@ -214,18 +214,18 @@ TString FormatExc(const std::exception& exception);
* @endcode
*/
#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__))
-
-/**
- * @def Y_ENSURE_BT
- *
- * This macro is inteded to use as a shortcut for `if () { throw TWithBackTrace<yexception>() << "message"; }`.
- *
- * @code
- * void DoSomethingLovely(const int x, const int y) {
- * Y_ENSURE_BT(x > y, "`x` must be greater than `y`");
- * Y_ENSURE_BT(x > y); // if you are too lazy
- * // actually doing something nice here
- * }
- * @endcode
- */
-#define Y_ENSURE_BT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_BT_IMPL_2, Y_ENSURE_BT_IMPL_1)(__VA_ARGS__))
+
+/**
+ * @def Y_ENSURE_BT
+ *
+ * This macro is inteded to use as a shortcut for `if () { throw TWithBackTrace<yexception>() << "message"; }`.
+ *
+ * @code
+ * void DoSomethingLovely(const int x, const int y) {
+ * Y_ENSURE_BT(x > y, "`x` must be greater than `y`");
+ * Y_ENSURE_BT(x > y); // if you are too lazy
+ * // actually doing something nice here
+ * }
+ * @endcode
+ */
+#define Y_ENSURE_BT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_BT_IMPL_2, Y_ENSURE_BT_IMPL_1)(__VA_ARGS__))
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index 732aa12656..cb3e29fed8 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -10,7 +10,7 @@ static inline void Throw2DontMove() {
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/algorithm.h>
+#include <util/generic/algorithm.h>
#include <util/memory/tempbuf.h>
#include <util/random/mersenne.h>
#include <util/stream/output.h>
@@ -32,9 +32,9 @@ static IOutputStream* OUTS = nullptr;
namespace NOuter::NInner {
void Compare10And20() {
Y_ENSURE(10 > 20);
- }
-}
-
+ }
+}
+
class TExceptionTest: public TTestBase {
UNIT_TEST_SUITE(TExceptionTest);
UNIT_TEST_EXCEPTION(TestException, yexception)
@@ -46,8 +46,8 @@ class TExceptionTest: public TTestBase {
UNIT_TEST(TestVirtualInheritance)
UNIT_TEST(TestMixedCode)
UNIT_TEST(TestBackTrace)
- UNIT_TEST(TestEnsureWithBackTrace1)
- UNIT_TEST(TestEnsureWithBackTrace2)
+ UNIT_TEST(TestEnsureWithBackTrace1)
+ UNIT_TEST(TestEnsureWithBackTrace2)
UNIT_TEST(TestRethrowAppend)
UNIT_TEST(TestMacroOverload)
UNIT_TEST(TestMessageCrop)
@@ -86,48 +86,48 @@ private:
UNIT_ASSERT(false);
}
- template <typename TException>
- static void EnsureCurrentExceptionHasBackTrace() {
- auto exceptionPtr = std::current_exception();
- UNIT_ASSERT_C(exceptionPtr != nullptr, "No exception");
- try {
- std::rethrow_exception(exceptionPtr);
- } catch (const TException& e) {
- const TBackTrace* bt = e.BackTrace();
- UNIT_ASSERT(bt != nullptr);
- } catch (...) {
- UNIT_ASSERT_C(false, "Unexpected exception type");
- }
- };
-
- inline void TestEnsureWithBackTrace1() {
- try {
- Y_ENSURE_BT(4 > 6);
- } catch (...) {
- const TString msg = CurrentExceptionMessage();
- UNIT_ASSERT(msg.Contains("4 > 6"));
- UNIT_ASSERT(msg.Contains("\n"));
- EnsureCurrentExceptionHasBackTrace<yexception>();
- return;
- }
- UNIT_ASSERT(false);
- }
-
- inline void TestEnsureWithBackTrace2() {
- try {
+ template <typename TException>
+ static void EnsureCurrentExceptionHasBackTrace() {
+ auto exceptionPtr = std::current_exception();
+ UNIT_ASSERT_C(exceptionPtr != nullptr, "No exception");
+ try {
+ std::rethrow_exception(exceptionPtr);
+ } catch (const TException& e) {
+ const TBackTrace* bt = e.BackTrace();
+ UNIT_ASSERT(bt != nullptr);
+ } catch (...) {
+ UNIT_ASSERT_C(false, "Unexpected exception type");
+ }
+ };
+
+ inline void TestEnsureWithBackTrace1() {
+ try {
+ Y_ENSURE_BT(4 > 6);
+ } catch (...) {
+ const TString msg = CurrentExceptionMessage();
+ UNIT_ASSERT(msg.Contains("4 > 6"));
+ UNIT_ASSERT(msg.Contains("\n"));
+ EnsureCurrentExceptionHasBackTrace<yexception>();
+ return;
+ }
+ UNIT_ASSERT(false);
+ }
+
+ inline void TestEnsureWithBackTrace2() {
+ try {
Y_ENSURE_BT(4 > 6, "custom "
<< "message");
- } catch (...) {
- const TString msg = CurrentExceptionMessage();
- UNIT_ASSERT(!msg.Contains("4 > 6"));
- UNIT_ASSERT(msg.Contains("custom message"));
- UNIT_ASSERT(msg.Contains("\n"));
- EnsureCurrentExceptionHasBackTrace<yexception>();
- return;
- }
- UNIT_ASSERT(false);
- }
-
+ } catch (...) {
+ const TString msg = CurrentExceptionMessage();
+ UNIT_ASSERT(!msg.Contains("4 > 6"));
+ UNIT_ASSERT(msg.Contains("custom message"));
+ UNIT_ASSERT(msg.Contains("\n"));
+ EnsureCurrentExceptionHasBackTrace<yexception>();
+ return;
+ }
+ UNIT_ASSERT(false);
+ }
+
inline void TestVirtualInheritance() {
TStringStream ss;
@@ -273,12 +273,12 @@ private:
} catch (const yexception& e) {
UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for"));
}
-
- try {
- NOuter::NInner::Compare10And20();
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
- }
+
+ try {
+ NOuter::NInner::Compare10And20();
+ } catch (const yexception& e) {
+ UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
+ }
}
void TestMessageCrop() {
diff --git a/util/memory/addstorage.h b/util/memory/addstorage.h
index 81c8260b9d..597c73a988 100644
--- a/util/memory/addstorage.h
+++ b/util/memory/addstorage.h
@@ -5,40 +5,40 @@
#include <new>
-namespace NPrivate {
- class TAdditionalStorageInfo {
+namespace NPrivate {
+ class TAdditionalStorageInfo {
public:
- constexpr TAdditionalStorageInfo(size_t length) noexcept
- : Length_(length)
- {
+ constexpr TAdditionalStorageInfo(size_t length) noexcept
+ : Length_(length)
+ {
}
- constexpr size_t Length() const noexcept {
- return Length_;
+ constexpr size_t Length() const noexcept {
+ return Length_;
}
private:
- size_t Length_;
+ size_t Length_;
};
-}
+}
+
+template <class T>
+class alignas(::NPrivate::TAdditionalStorageInfo) TAdditionalStorage {
+ using TInfo = ::NPrivate::TAdditionalStorageInfo;
-template <class T>
-class alignas(::NPrivate::TAdditionalStorageInfo) TAdditionalStorage {
- using TInfo = ::NPrivate::TAdditionalStorageInfo;
-
public:
inline TAdditionalStorage() noexcept = default;
inline ~TAdditionalStorage() = default;
inline void* operator new(size_t len1, size_t len2) {
- static_assert(alignof(T) >= alignof(TInfo));
- Y_ASSERT(len1 == sizeof(T));
- void* data = ::operator new(CombinedSizeOfInstanceWithTInfo() + len2);
- void* info = InfoPtr(static_cast<T*>(data));
- Y_UNUSED(new (info) TInfo(len2));
+ static_assert(alignof(T) >= alignof(TInfo));
+ Y_ASSERT(len1 == sizeof(T));
+ void* data = ::operator new(CombinedSizeOfInstanceWithTInfo() + len2);
+ void* info = InfoPtr(static_cast<T*>(data));
+ Y_UNUSED(new (info) TInfo(len2));
- return data;
+ return data;
}
inline void operator delete(void* ptr) noexcept {
@@ -58,36 +58,36 @@ public:
}
inline void* AdditionalData() const noexcept {
- return (char*)(static_cast<const T*>(this)) + CombinedSizeOfInstanceWithTInfo();
+ return (char*)(static_cast<const T*>(this)) + CombinedSizeOfInstanceWithTInfo();
}
static inline T* ObjectFromData(void* data) noexcept {
- return reinterpret_cast<T*>(static_cast<char*>(data) - CombinedSizeOfInstanceWithTInfo());
+ return reinterpret_cast<T*>(static_cast<char*>(data) - CombinedSizeOfInstanceWithTInfo());
}
inline size_t AdditionalDataLength() const noexcept {
- return InfoPtr(static_cast<const T*>(this))->Length();
+ return InfoPtr(static_cast<const T*>(this))->Length();
}
private:
static inline void DoDelete(void* ptr) noexcept {
- TInfo* info = InfoPtr(static_cast<T*>(ptr));
+ TInfo* info = InfoPtr(static_cast<T*>(ptr));
info->~TInfo();
- ::operator delete(ptr);
+ ::operator delete(ptr);
+ }
+
+ static constexpr size_t CombinedSizeOfInstanceWithTInfo() noexcept {
+ return AlignUp(sizeof(T), alignof(TInfo)) + sizeof(TInfo);
+ }
+
+ static constexpr TInfo* InfoPtr(T* instance) noexcept {
+ return const_cast<TInfo*>(InfoPtr(static_cast<const T*>(instance)));
+ }
+
+ static constexpr const TInfo* InfoPtr(const T* instance) noexcept {
+ return reinterpret_cast<const TInfo*>(reinterpret_cast<const char*>(instance) + CombinedSizeOfInstanceWithTInfo() - sizeof(TInfo));
}
- static constexpr size_t CombinedSizeOfInstanceWithTInfo() noexcept {
- return AlignUp(sizeof(T), alignof(TInfo)) + sizeof(TInfo);
- }
-
- static constexpr TInfo* InfoPtr(T* instance) noexcept {
- return const_cast<TInfo*>(InfoPtr(static_cast<const T*>(instance)));
- }
-
- static constexpr const TInfo* InfoPtr(const T* instance) noexcept {
- return reinterpret_cast<const TInfo*>(reinterpret_cast<const char*>(instance) + CombinedSizeOfInstanceWithTInfo() - sizeof(TInfo));
- }
-
private:
- void* operator new(size_t) = delete;
+ void* operator new(size_t) = delete;
};
diff --git a/util/memory/benchmark/pool/metrics/ya.make b/util/memory/benchmark/pool/metrics/ya.make
index 5dcd3f8343..c671bc5c1c 100644
--- a/util/memory/benchmark/pool/metrics/ya.make
+++ b/util/memory/benchmark/pool/metrics/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/memory/benchmark/pool/ya.make b/util/memory/benchmark/pool/ya.make
index 85199aa3af..5f4f7d3f15 100644
--- a/util/memory/benchmark/pool/ya.make
+++ b/util/memory/benchmark/pool/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/memory/benchmark/ya.make b/util/memory/benchmark/ya.make
index 0fe18aae9d..2259b9434e 100644
--- a/util/memory/benchmark/ya.make
+++ b/util/memory/benchmark/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
pool
diff --git a/util/memory/blob.h b/util/memory/blob.h
index d13b2d3db4..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -74,12 +74,12 @@ public:
Ref();
}
- TBlob(TBlob&& r) noexcept
- : TBlob()
- {
- this->Swap(r);
- }
-
+ TBlob(TBlob&& r) noexcept
+ : TBlob()
+ {
+ this->Swap(r);
+ }
+
inline TBlob(const void* data, size_t length, TBase* base) noexcept
: S_(data, length, base)
{
diff --git a/util/memory/ut/ya.make b/util/memory/ut/ya.make
index 69ec434d04..d3a988617d 100644
--- a/util/memory/ut/ya.make
+++ b/util/memory/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
memory/addstorage_ut.cpp
diff --git a/util/memory/ya.make b/util/memory/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/memory/ya.make
+++ b/util/memory/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/network/ut/ya.make b/util/network/ut/ya.make
index d7efebea81..1ba03e167c 100644
--- a/util/network/ut/ya.make
+++ b/util/network/ut/ya.make
@@ -3,7 +3,7 @@ UNITTEST_FOR(util)
REQUIREMENTS(network:full)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PEERDIR(
library/cpp/threading/future
diff --git a/util/network/ya.make b/util/network/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/network/ya.make
+++ b/util/network/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/random/benchmark/prng/metrics/ya.make b/util/random/benchmark/prng/metrics/ya.make
index 35f405950e..1f56aac0bd 100644
--- a/util/random/benchmark/prng/metrics/ya.make
+++ b/util/random/benchmark/prng/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/random/benchmark/prng/ya.make b/util/random/benchmark/prng/ya.make
index 7ba0dcee94..976977014f 100644
--- a/util/random/benchmark/prng/ya.make
+++ b/util/random/benchmark/prng/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/random/benchmark/ya.make b/util/random/benchmark/ya.make
index 0836e6a93c..7d753ae6e7 100644
--- a/util/random/benchmark/ya.make
+++ b/util/random/benchmark/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
prng
diff --git a/util/random/ut/ya.make b/util/random/ut/ya.make
index 93e3923c11..5080b339de 100644
--- a/util/random/ut/ya.make
+++ b/util/random/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
random/common_ops_ut.cpp
diff --git a/util/random/ya.make b/util/random/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/random/ya.make
+++ b/util/random/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/stream/ut/ya.make b/util/stream/ut/ya.make
index bf7e9a42c5..f0176dd7b4 100644
--- a/util/stream/ut/ya.make
+++ b/util/stream/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
stream/aligned_ut.cpp
diff --git a/util/stream/ya.make b/util/stream/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/stream/ya.make
+++ b/util/stream/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/string/benchmark/float_to_string/metrics/ya.make b/util/string/benchmark/float_to_string/metrics/ya.make
index 37581c70bd..4b8c4cc07d 100644
--- a/util/string/benchmark/float_to_string/metrics/ya.make
+++ b/util/string/benchmark/float_to_string/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/string/benchmark/join/metrics/ya.make b/util/string/benchmark/join/metrics/ya.make
index b990afb922..08ff3a149f 100644
--- a/util/string/benchmark/join/metrics/ya.make
+++ b/util/string/benchmark/join/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
salmin
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/string/benchmark/join/ya.make b/util/string/benchmark/join/ya.make
index 4ea53d87cb..dfcc1d264e 100644
--- a/util/string/benchmark/join/ya.make
+++ b/util/string/benchmark/join/ya.make
@@ -4,7 +4,7 @@ OWNER(
salmin
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/string/benchmark/subst_global/metrics/ya.make b/util/string/benchmark/subst_global/metrics/ya.make
index d1fd54176c..d8c30ad460 100644
--- a/util/string/benchmark/subst_global/metrics/ya.make
+++ b/util/string/benchmark/subst_global/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/string/benchmark/ya.make b/util/string/benchmark/ya.make
index 0627a50e3c..266b53c7b3 100644
--- a/util/string/benchmark/ya.make
+++ b/util/string/benchmark/ya.make
@@ -2,7 +2,7 @@ OWNER(
g:util
yazevnul
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
ascii
diff --git a/util/string/fuzzing/collapse/ya.make b/util/string/fuzzing/collapse/ya.make
index 9c3ee10b1d..b8614f6411 100644
--- a/util/string/fuzzing/collapse/ya.make
+++ b/util/string/fuzzing/collapse/ya.make
@@ -4,7 +4,7 @@ OWNER(
pg
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/string/fuzzing/escape_c/ya.make b/util/string/fuzzing/escape_c/ya.make
index be1a25e43c..61e64ac9de 100644
--- a/util/string/fuzzing/escape_c/ya.make
+++ b/util/string/fuzzing/escape_c/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
FUZZ()
diff --git a/util/string/fuzzing/strtod/ya.make b/util/string/fuzzing/strtod/ya.make
index 9c3ee10b1d..b8614f6411 100644
--- a/util/string/fuzzing/strtod/ya.make
+++ b/util/string/fuzzing/strtod/ya.make
@@ -4,7 +4,7 @@ OWNER(
pg
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/string/fuzzing/ya.make b/util/string/fuzzing/ya.make
index b08f4d2b6c..617e0f2b1d 100644
--- a/util/string/fuzzing/ya.make
+++ b/util/string/fuzzing/ya.make
@@ -2,7 +2,7 @@ OWNER(
g:util
pg
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
collapse
diff --git a/util/string/join.h b/util/string/join.h
index 62ace2fb17..b166fad1f3 100644
--- a/util/string/join.h
+++ b/util/string/join.h
@@ -169,9 +169,9 @@ TUtf32String JoinRange(wchar32 delim, const TIter beg, const TIter end) {
template <typename TCharType, typename TContainer>
inline TBasicString<TCharType> JoinSeq(std::basic_string_view<TCharType> delim, const TContainer& data) {
- using std::begin;
- using std::end;
- return JoinRange(delim, begin(data), end(data));
+ using std::begin;
+ using std::end;
+ return JoinRange(delim, begin(data), end(data));
}
template <typename TCharType, typename TContainer>
diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp
index 645a235ad6..3ed2b2459c 100644
--- a/util/string/join_ut.cpp
+++ b/util/string/join_ut.cpp
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
UNIT_ASSERT_EQUAL(JoinSeq(" ", {}), "");
UNIT_ASSERT_EQUAL(JoinSeq(" ", {42}), "42");
UNIT_ASSERT_EQUAL(JoinSeq(" ", {1, 2, 3}), "1 2 3");
- UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), "1 2 3");
+ UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), "1 2 3");
}
Y_UNIT_TEST(StrContainerItems) {
@@ -143,9 +143,9 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
stream << MakeRangeJoiner(" ", std::initializer_list<TString>{vstring[0], vstring[1], vstring[2]});
UNIT_ASSERT_EQUAL(stream.Str(), result);
}
-
- // c-style array
- UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), result);
+
+ // c-style array
+ UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), result);
}
Y_UNIT_TEST(CustomToString) {
diff --git a/util/string/split.h b/util/string/split.h
index 626ad69cda..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -508,11 +508,11 @@ namespace NStringSplitPrivate {
*dst = src;
}
- template <class T>
- inline void DoFromString(const T& src, decltype(std::ignore)* dst) noexcept {
- *dst = src;
- }
-
+ template <class T>
+ inline void DoFromString(const T& src, decltype(std::ignore)* dst) noexcept {
+ *dst = src;
+ }
+
template <class Src, class Dst>
inline Y_WARN_UNUSED_RESULT bool TryDoFromString(const Src& src, Dst* dst) noexcept {
return ::TryFromString(src, *dst);
@@ -524,12 +524,12 @@ namespace NStringSplitPrivate {
return true;
}
- template <class T>
- inline Y_WARN_UNUSED_RESULT bool TryDoFromString(const T& src, decltype(std::ignore)* dst) noexcept {
- *dst = src;
- return true;
- }
-
+ template <class T>
+ inline Y_WARN_UNUSED_RESULT bool TryDoFromString(const T& src, decltype(std::ignore)* dst) noexcept {
+ *dst = src;
+ return true;
+ }
+
/**
* Consumer that places provided elements into a container. Not using
* `emplace(iterator)` for efficiency.
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp
index 3ec9b302be..43e59f2d75 100644
--- a/util/string/split_ut.cpp
+++ b/util/string/split_ut.cpp
@@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConvertingConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestCharSkipEmpty) {
+ Y_UNIT_TEST(TestCharSkipEmpty) {
TString data("qw ab qwabcab ");
TString canonic[] = {"qw", "ab", "qwabcab"};
TVector<TString> good(canonic, canonic + 3);
@@ -559,14 +559,14 @@ Y_UNIT_TEST_SUITE(StringSplitter) {
UNIT_ASSERT_EXCEPTION(StringSplitter("1 2 3").Split(' ').CollectInto(&a, &a), yexception);
}
- Y_UNIT_TEST(TestSplitStringWithIgnore) {
- TStringBuf s;
- StringSplitter("x y z").Split(' ').CollectInto(&std::ignore, &s, &std::ignore);
- UNIT_ASSERT_VALUES_EQUAL(s, "y");
-
- UNIT_ASSERT_EXCEPTION(StringSplitter("ignored != non-requred").Split(':').CollectInto(&s, &std::ignore), yexception);
- }
-
+ Y_UNIT_TEST(TestSplitStringWithIgnore) {
+ TStringBuf s;
+ StringSplitter("x y z").Split(' ').CollectInto(&std::ignore, &s, &std::ignore);
+ UNIT_ASSERT_VALUES_EQUAL(s, "y");
+
+ UNIT_ASSERT_EXCEPTION(StringSplitter("ignored != non-requred").Split(':').CollectInto(&s, &std::ignore), yexception);
+ }
+
Y_UNIT_TEST(TestTryCollectInto) {
int a, b, c;
bool parsingSucceeded;
diff --git a/util/string/ut/ya.make b/util/string/ut/ya.make
index 654d053852..6e80812825 100644
--- a/util/string/ut/ya.make
+++ b/util/string/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
string/builder_ut.cpp
diff --git a/util/string/ya.make b/util/string/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/string/ya.make
+++ b/util/string/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp
index 9f77f07a06..74fb10b6b1 100644
--- a/util/system/atexit.cpp
+++ b/util/system/atexit.cpp
@@ -1,5 +1,5 @@
#include "atexit.h"
-#include "atomic.h"
+#include "atomic.h"
#include "yassert.h"
#include "spinlock.h"
#include "thread.h"
@@ -77,29 +77,29 @@ namespace {
};
static TAtomic atExitLock = 0;
- static TAtExit* volatile atExitPtr = nullptr;
+ static TAtExit* volatile atExitPtr = nullptr;
alignas(TAtExit) static char atExitMem[sizeof(TAtExit)];
static void OnExit() {
- if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
+ if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
atExit->Finish();
atExit->~TAtExit();
- AtomicSet(atExitPtr, nullptr);
+ AtomicSet(atExitPtr, nullptr);
}
}
static inline TAtExit* Instance() {
- if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
- return atExit;
- }
+ if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
+ return atExit;
+ }
with_lock (atExitLock) {
- if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
- return atExit;
+ if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
+ return atExit;
}
- atexit(OnExit);
- TAtExit* const atExit = new (atExitMem) TAtExit;
- AtomicSet(atExitPtr, atExit);
- return atExit;
+ atexit(OnExit);
+ TAtExit* const atExit = new (atExitMem) TAtExit;
+ AtomicSet(atExitPtr, atExit);
+ return atExit;
}
}
}
@@ -109,10 +109,10 @@ void ManualRunAtExitFinalizers() {
}
bool ExitStarted() {
- if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
- return atExit->FinishStarted();
+ if (TAtExit* const atExit = AtomicGet(atExitPtr)) {
+ return atExit->FinishStarted();
}
- return false;
+ return false;
}
void AtExit(TAtExitFunc func, void* ctx, size_t priority) {
diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make
index f22decac96..8c55def99b 100644
--- a/util/system/benchmark/cpu_id/metrics/ya.make
+++ b/util/system/benchmark/cpu_id/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/system/benchmark/cpu_id/ya.make b/util/system/benchmark/cpu_id/ya.make
index 7ba0dcee94..976977014f 100644
--- a/util/system/benchmark/cpu_id/ya.make
+++ b/util/system/benchmark/cpu_id/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make
index 0576c4d9cf..d526487e1a 100644
--- a/util/system/benchmark/create_destroy_thread/metrics/ya.make
+++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/system/benchmark/rdtsc/ya.make b/util/system/benchmark/rdtsc/ya.make
index 5628d4fb8a..7059abc3a4 100644
--- a/util/system/benchmark/rdtsc/ya.make
+++ b/util/system/benchmark/rdtsc/ya.make
@@ -1,7 +1,7 @@
Y_BENCHMARK()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/system/benchmark/ya.make b/util/system/benchmark/ya.make
index dc009eea23..12fa9af9d6 100644
--- a/util/system/benchmark/ya.make
+++ b/util/system/benchmark/ya.make
@@ -2,7 +2,7 @@ OWNER(
yazevnul
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
cpu_id
diff --git a/util/system/guard_ut.cpp b/util/system/guard_ut.cpp
index 6cb9079211..404ede99ab 100644
--- a/util/system/guard_ut.cpp
+++ b/util/system/guard_ut.cpp
@@ -14,7 +14,7 @@ struct TTestGuard: public TTestBase {
UNIT_TEST(TestUnguard)
UNIT_TEST(TestTryReadGuard)
UNIT_TEST(TestWithLock)
- UNIT_TEST(TestWithLockScope);
+ UNIT_TEST(TestWithLockScope);
UNIT_TEST_SUITE_END();
struct TGuardChecker {
@@ -167,14 +167,14 @@ struct TTestGuard: public TTestBase {
UNIT_ASSERT(!m.guarded);
UNIT_ASSERT_EQUAL(n, 43);
}
-
- void TestWithLockScope() {
- auto Guard = [](auto) { UNIT_FAIL("Non global Guard used"); return 0; };
- TGuardChecker m;
+
+ void TestWithLockScope() {
+ auto Guard = [](auto) { UNIT_FAIL("Non global Guard used"); return 0; };
+ TGuardChecker m;
with_lock (m) {
- Y_UNUSED(Guard);
- }
- }
+ Y_UNUSED(Guard);
+ }
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TTestGuard)
diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h
index 501693535d..965e5c751e 100644
--- a/util/system/sanitizers.h
+++ b/util/system/sanitizers.h
@@ -55,7 +55,7 @@ namespace NSan {
}
// Determines if asan present
- inline constexpr static bool ASanIsOn() noexcept {
+ inline constexpr static bool ASanIsOn() noexcept {
#if defined(_asan_enabled_)
return true;
#else
@@ -64,7 +64,7 @@ namespace NSan {
}
// Determines if tsan present
- inline constexpr static bool TSanIsOn() noexcept {
+ inline constexpr static bool TSanIsOn() noexcept {
#if defined(_tsan_enabled_)
return true;
#else
@@ -73,7 +73,7 @@ namespace NSan {
}
// Determines if msan present
- inline constexpr static bool MSanIsOn() noexcept {
+ inline constexpr static bool MSanIsOn() noexcept {
#if defined(_msan_enabled_)
return true;
#else
diff --git a/util/system/src_location.h b/util/system/src_location.h
index 0117cdebf8..12ba6e063e 100644
--- a/util/system/src_location.h
+++ b/util/system/src_location.h
@@ -15,11 +15,11 @@ struct TSourceLocation {
int Line;
};
-// __SOURCE_FILE__ should be used instead of __FILE__
-#if !defined(__NVCC__)
+// __SOURCE_FILE__ should be used instead of __FILE__
+#if !defined(__NVCC__)
#define __SOURCE_FILE__ (__SOURCE_FILE_IMPL__.As<TStringBuf>())
-#else
+#else
#define __SOURCE_FILE__ (__SOURCE_FILE_IMPL__.template As<TStringBuf>())
-#endif
-
+#endif
+
#define __LOCATION__ ::TSourceLocation(__SOURCE_FILE__, __LINE__)
diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp
index 5e880d950b..5b86cb86ef 100644
--- a/util/system/src_location_ut.cpp
+++ b/util/system/src_location_ut.cpp
@@ -11,8 +11,8 @@ static inline TString GenLoc() {
Y_UNIT_TEST_SUITE(TestLocation) {
Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(GenLoc(), "util/system/src_location_ut.cpp:8");
-
- static constexpr TSourceLocation location = __LOCATION__;
- static_assert(location.Line >= 0, "__LOCATION__ can be used at compile time expressions");
+
+ static constexpr TSourceLocation location = __LOCATION__;
+ static_assert(location.Line >= 0, "__LOCATION__ can be used at compile time expressions");
}
}
diff --git a/util/system/src_root.h b/util/system/src_root.h
index 17bea82be5..4f2d9f5ee6 100644
--- a/util/system/src_root.h
+++ b/util/system/src_root.h
@@ -3,8 +3,8 @@
#include "compiler.h"
#include "defaults.h"
-#include <type_traits>
-
+#include <type_traits>
+
namespace NPrivate {
struct TStaticBuf {
constexpr TStaticBuf(const char* data, unsigned len) noexcept
@@ -32,37 +32,37 @@ namespace NPrivate {
constexpr TStaticBuf ArcRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_ROOT));
constexpr TStaticBuf BuildRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_BUILD_ROOT));
- constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept {
- if (prefix.Len < string.Len) {
- for (unsigned i = prefix.Len; i-- > 0;) {
- if (prefix.Data[i] != string.Data[i]) {
- return false;
- }
- }
- return true;
- } else {
- return false;
- }
- }
-
- constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept {
- if (IsProperPrefix(ArcRoot, f)) {
- return ArcRoot.Len + 1;
+ constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept {
+ if (prefix.Len < string.Len) {
+ for (unsigned i = prefix.Len; i-- > 0;) {
+ if (prefix.Data[i] != string.Data[i]) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept {
+ if (IsProperPrefix(ArcRoot, f)) {
+ return ArcRoot.Len + 1;
}
- if (IsProperPrefix(BuildRoot, f)) {
- return BuildRoot.Len + 1;
+ if (IsProperPrefix(BuildRoot, f)) {
+ return BuildRoot.Len + 1;
}
- return 0;
+ return 0;
+ }
+
+ constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept {
+ return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength);
+ }
+
+ //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp
+ constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept {
+ return StripRoot(f, RootPrefixLength(f));
}
-
- constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept {
- return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength);
- }
-
- //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp
- constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept {
- return StripRoot(f, RootPrefixLength(f));
- }
}
-#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value)
+#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value)
diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp
index 852f9dd668..e9a675eb9a 100644
--- a/util/system/src_root_ut.cpp
+++ b/util/system/src_root_ut.cpp
@@ -9,19 +9,19 @@ Y_UNIT_TEST_SUITE(TestSourceRoot) {
const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct();
UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp");
}
-
- Y_UNIT_TEST(TestPrivateChopPrefixRoutine) {
- static constexpr const char str[] = ":\0:\0: It's unlikely that this string has an ARCADIA_ROOT as its prefix :\0:\0:";
- static constexpr const auto strStaticBuf = STATIC_BUF(str);
+
+ Y_UNIT_TEST(TestPrivateChopPrefixRoutine) {
+ static constexpr const char str[] = ":\0:\0: It's unlikely that this string has an ARCADIA_ROOT as its prefix :\0:\0:";
+ static constexpr const auto strStaticBuf = STATIC_BUF(str);
UNIT_ASSERT_VALUES_EQUAL(TStringBuf(str, sizeof(str) - 1), ::NPrivate::StripRoot(strStaticBuf).As<TStringBuf>());
- UNIT_ASSERT_VALUES_EQUAL(0, ::NPrivate::RootPrefixLength(strStaticBuf));
-
- static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("foo"), STATIC_BUF("foobar")), R"(IsProperPrefix("foo", "foobar") failed)");
- static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("foobar"), STATIC_BUF("foo")), R"(IsProperPrefix("foobar", "foo") failed)");
- static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name")), R"(IsProperPrefix("name", "name") failed)");
- static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name/")), R"(IsProperPrefix("name", "name/") failed)");
- static_assert(::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("foobar")), R"(IsProperPrefix("", "foobar") failed)");
- static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("")), R"(IsProperPrefix("", "") failed)");
- static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("dir"), STATIC_BUF("dir/file")), R"(IsProperPrefix("dir", "dir/file") failed)");
- }
+ UNIT_ASSERT_VALUES_EQUAL(0, ::NPrivate::RootPrefixLength(strStaticBuf));
+
+ static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("foo"), STATIC_BUF("foobar")), R"(IsProperPrefix("foo", "foobar") failed)");
+ static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("foobar"), STATIC_BUF("foo")), R"(IsProperPrefix("foobar", "foo") failed)");
+ static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name")), R"(IsProperPrefix("name", "name") failed)");
+ static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name/")), R"(IsProperPrefix("name", "name/") failed)");
+ static_assert(::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("foobar")), R"(IsProperPrefix("", "foobar") failed)");
+ static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("")), R"(IsProperPrefix("", "") failed)");
+ static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("dir"), STATIC_BUF("dir/file")), R"(IsProperPrefix("dir", "dir/file") failed)");
+ }
}
diff --git a/util/system/ut/stdin_osfhandle/ya.make b/util/system/ut/stdin_osfhandle/ya.make
index 5d3701adf0..d71ab22e69 100644
--- a/util/system/ut/stdin_osfhandle/ya.make
+++ b/util/system/ut/stdin_osfhandle/ya.make
@@ -1,7 +1,7 @@
PROGRAM()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
main.cpp
diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make
index 6b758d2f48..127e7c261e 100644
--- a/util/system/ut/ya.make
+++ b/util/system/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
FORK_TESTS()
diff --git a/util/system/ya.make b/util/system/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/system/ya.make
+++ b/util/system/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp
index 60dbe4c04a..0f586648b7 100644
--- a/util/system/yassert.cpp
+++ b/util/system/yassert.cpp
@@ -7,7 +7,7 @@
#include <util/datetime/base.h>
#include <util/generic/singleton.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
#include <util/stream/output.h>
#include <util/stream/str.h>
@@ -34,9 +34,9 @@ namespace {
struct TPanicLockHolder: public TAdaptiveLock {
};
}
-namespace NPrivate {
- [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept;
-}
+namespace NPrivate {
+ [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept;
+}
void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, const char* expr, const char* format, ...) noexcept {
try {
@@ -51,18 +51,18 @@ void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, c
vsprintf(errorMsg, format[0] == ' ' ? format + 1 : format, args);
va_end(args);
- constexpr int abiPlaceholder = 0;
- ::NPrivate::InternalPanicImpl(line, function, expr, abiPlaceholder, abiPlaceholder, abiPlaceholder, file.As<TStringBuf>(), errorMsg.c_str(), errorMsg.size());
- } catch (...) {
- // ¯\_(ツ)_/¯
- }
-
- abort();
-}
-
-namespace NPrivate {
- [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try {
- TStringBuf errorMsg{errorMessage, errorMessageSize};
+ constexpr int abiPlaceholder = 0;
+ ::NPrivate::InternalPanicImpl(line, function, expr, abiPlaceholder, abiPlaceholder, abiPlaceholder, file.As<TStringBuf>(), errorMsg.c_str(), errorMsg.size());
+ } catch (...) {
+ // ¯\_(ツ)_/¯
+ }
+
+ abort();
+}
+
+namespace NPrivate {
+ [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try {
+ TStringBuf errorMsg{errorMessage, errorMessageSize};
const TString now = TInstant::Now().ToStringLocal();
TString r;
@@ -72,7 +72,7 @@ namespace NPrivate {
} else {
o << "FAIL (" << now << "): " << errorMsg << Endl;
}
- o << " " << file << ":" << line << Endl;
+ o << " " << file << ":" << line << Endl;
if (expr) {
o << " " << function << "(): requirement " << expr << " failed" << Endl;
} else {
@@ -87,8 +87,8 @@ namespace NPrivate {
Cerr << "Failed to dump clang coverage" << Endl;
}
#endif
- abort();
+ abort();
} catch (...) {
- abort();
+ abort();
}
}
diff --git a/util/tests/benchmark/ya.make b/util/tests/benchmark/ya.make
index 17cd785b3e..134cbfabd1 100644
--- a/util/tests/benchmark/ya.make
+++ b/util/tests/benchmark/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE_ROOT_RELATIVE(
util/charset/benchmark
diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make
index c54ab832f6..b928c19026 100644
--- a/util/tests/cython/ya.make
+++ b/util/tests/cython/ya.make
@@ -1,7 +1,7 @@
PY23_TEST()
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCDIR(util)
diff --git a/util/tests/fuzzing/ya.make b/util/tests/fuzzing/ya.make
index 8b47fa9f61..d9a8f9df9f 100644
--- a/util/tests/fuzzing/ya.make
+++ b/util/tests/fuzzing/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE_ROOT_RELATIVE(
util/string/fuzzing
diff --git a/util/tests/sym_versions/ya.make b/util/tests/sym_versions/ya.make
index 73e2b3a70b..3957c60fc9 100644
--- a/util/tests/sym_versions/ya.make
+++ b/util/tests/sym_versions/ya.make
@@ -4,7 +4,7 @@ OWNER(
pg
g:util
)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
TEST_SRCS(test_glibc.py)
diff --git a/util/tests/ut/ya.make b/util/tests/ut/ya.make
index 30fc35ce9c..94278cbde1 100644
--- a/util/tests/ut/ya.make
+++ b/util/tests/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
ysaveload_ut.cpp
diff --git a/util/thread/lfqueue_ut.cpp b/util/thread/lfqueue_ut.cpp
index 25dd246d89..83bca100cf 100644
--- a/util/thread/lfqueue_ut.cpp
+++ b/util/thread/lfqueue_ut.cpp
@@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
});
}
- NThreading::WaitExceptionOrAll(futures).GetValueSync();
+ NThreading::WaitExceptionOrAll(futures).GetValueSync();
p.Stop();
TVector<int> left;
diff --git a/util/thread/ut/ya.make b/util/thread/ut/ya.make
index ff0e1f6970..93198bfaf1 100644
--- a/util/thread/ut/ya.make
+++ b/util/thread/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
thread/factory_ut.cpp
diff --git a/util/thread/ya.make b/util/thread/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/thread/ya.make
+++ b/util/thread/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/util/ya.make b/util/ya.make
index fb0e134e7a..6ebe7e40cf 100644
--- a/util/ya.make
+++ b/util/ya.make
@@ -65,7 +65,7 @@ JOIN_SRCS(
folder/dirut.cpp
folder/filelist.cpp
folder/fts.cpp
- folder/fwd.cpp
+ folder/fwd.cpp
folder/iterator.cpp
folder/path.cpp
folder/pathsplit.cpp
@@ -119,7 +119,7 @@ JOIN_SRCS(
generic/ptr.cpp
generic/queue.cpp
generic/refcount.cpp
- generic/serialized_enum.cpp
+ generic/serialized_enum.cpp
generic/set.cpp
generic/singleton.cpp
generic/size_literals.cpp
@@ -381,7 +381,7 @@ JOIN_SRCS(
)
END()
-
-RECURSE_FOR_TESTS(
- tests/ut
-)
+
+RECURSE_FOR_TESTS(
+ tests/ut
+)
diff --git a/util/ysaveload.cpp b/util/ysaveload.cpp
index 8472ad4e72..1ae3acb01e 100644
--- a/util/ysaveload.cpp
+++ b/util/ysaveload.cpp
@@ -12,11 +12,11 @@ void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) {
buf.Resize(s);
::LoadPodArray(rh, buf.Data(), buf.Size());
}
-
-[[noreturn]] void NPrivate::ThrowLoadEOFException(size_t typeSize, size_t realSize, TStringBuf structName) {
- ythrow TLoadEOF() << "can not load " << structName << "(" << typeSize << ", " << realSize << " bytes)";
-}
-
-[[noreturn]] void NPrivate::ThrowUnexpectedVariantTagException(ui8 tagIndex) {
- ythrow TLoadEOF() << "Unexpected tag value " << tagIndex << " while loading TVariant";
-}
+
+[[noreturn]] void NPrivate::ThrowLoadEOFException(size_t typeSize, size_t realSize, TStringBuf structName) {
+ ythrow TLoadEOF() << "can not load " << structName << "(" << typeSize << ", " << realSize << " bytes)";
+}
+
+[[noreturn]] void NPrivate::ThrowUnexpectedVariantTagException(ui8 tagIndex) {
+ ythrow TLoadEOF() << "Unexpected tag value " << tagIndex << " while loading TVariant";
+}
diff --git a/util/ysaveload.h b/util/ysaveload.h
index aaeb9159e1..02efb4049b 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/fwd.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
@@ -54,16 +54,16 @@ static inline void SavePodType(IOutputStream* rh, const T& t) {
rh->Write(&t, sizeof(T));
}
-namespace NPrivate {
- [[noreturn]] void ThrowLoadEOFException(size_t typeSize, size_t realSize, TStringBuf structName);
- [[noreturn]] void ThrowUnexpectedVariantTagException(ui8 tagIndex);
-}
-
+namespace NPrivate {
+ [[noreturn]] void ThrowLoadEOFException(size_t typeSize, size_t realSize, TStringBuf structName);
+ [[noreturn]] void ThrowUnexpectedVariantTagException(ui8 tagIndex);
+}
+
template <class T>
static inline void LoadPodType(IInputStream* rh, T& t) {
const size_t res = rh->Load(&t, sizeof(T));
- if (Y_UNLIKELY(res != sizeof(T))) {
+ if (Y_UNLIKELY(res != sizeof(T))) {
::NPrivate::ThrowLoadEOFException(sizeof(T), res, TStringBuf("pod type"));
}
}
@@ -78,7 +78,7 @@ static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) {
const size_t len = sizeof(T) * count;
const size_t res = rh->Load(arr, len);
- if (Y_UNLIKELY(res != len)) {
+ if (Y_UNLIKELY(res != len)) {
::NPrivate::ThrowLoadEOFException(len, res, TStringBuf("pod array"));
}
}
@@ -666,8 +666,8 @@ struct TSerializer<std::variant<Args...>> {
static void Load(IInputStream* is, TVar& v) {
ui8 index;
::Load(is, index);
- if (Y_UNLIKELY(index >= sizeof...(Args))) {
- ::NPrivate::ThrowUnexpectedVariantTagException(index);
+ if (Y_UNLIKELY(index >= sizeof...(Args))) {
+ ::NPrivate::ThrowUnexpectedVariantTagException(index);
}
LoadImpl(is, v, index, std::index_sequence_for<Args...>{});
}
@@ -720,17 +720,17 @@ static inline void LoadMany(S* s, Ts&... t) {
void Load(IInputStream* s) override { \
::LoadMany(s, __VA_ARGS__); \
}
-
-template <class T>
-struct TNonVirtualSaver {
- const T* Data;
- void Save(IOutputStream* out) const {
- Data->T::Save(out);
- }
-};
-
-template <typename S, typename T, typename... R>
-inline void LoadMany(S* s, TNonVirtualSaver<T> t, R&... r) {
- const_cast<T*>(t.Data)->T::Load(s);
- ::LoadMany(s, r...);
-}
+
+template <class T>
+struct TNonVirtualSaver {
+ const T* Data;
+ void Save(IOutputStream* out) const {
+ Data->T::Save(out);
+ }
+};
+
+template <typename S, typename T, typename... R>
+inline void LoadMany(S* s, TNonVirtualSaver<T> t, R&... r) {
+ const_cast<T*>(t.Data)->T::Load(s);
+ ::LoadMany(s, r...);
+}
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp
index 49bfbc3d7f..723c68f391 100644
--- a/util/ysaveload_ut.cpp
+++ b/util/ysaveload_ut.cpp
@@ -29,8 +29,8 @@ class TSaveLoadTest: public TTestBase {
UNIT_TEST(TestList)
UNIT_TEST(TestTuple)
UNIT_TEST(TestVariant)
- UNIT_TEST(TestInheritNonVirtualClass)
- UNIT_TEST(TestInheritVirtualClass)
+ UNIT_TEST(TestInheritNonVirtualClass)
+ UNIT_TEST(TestInheritVirtualClass)
UNIT_TEST_SUITE_END();
struct TSaveHelper {
@@ -430,58 +430,58 @@ private:
std::variant<char, bool> v2 = false;
UNIT_ASSERT_EXCEPTION(::Load(&s, v2), TLoadEOF);
}
-
- // tests serialization of class with three public string members
- template <class TDerived, class TInterface = TDerived>
- void TestInheritClassImpl() {
- TBufferStream s;
- {
- TDerived v1;
- v1.Str1 = "One";
- v1.Str2 = "Two";
- v1.Str3 = "Three";
- ::Save(&s, static_cast<const TInterface&>(v1));
- }
- {
- TDerived v2;
- ::Load(&s, static_cast<TInterface&>(v2));
- UNIT_ASSERT_VALUES_EQUAL_C(v2.Str1, "One", TypeName<TDerived>() << " via " << TypeName<TInterface>());
- UNIT_ASSERT_VALUES_EQUAL_C(v2.Str2, "Two", TypeName<TDerived>() << " via " << TypeName<TInterface>());
- UNIT_ASSERT_VALUES_EQUAL_C(v2.Str3, "Three", TypeName<TDerived>() << " via " << TypeName<TInterface>());
- }
- }
-
- void TestInheritNonVirtualClass() {
- struct TBaseNonVirtual {
- TString Str1;
- Y_SAVELOAD_DEFINE(Str1);
- };
- struct TDerivedNonVirtual: TBaseNonVirtual {
- TString Str2;
- TString Str3;
- Y_SAVELOAD_DEFINE(TNonVirtualSaver<TBaseNonVirtual>{this}, Str2, Str3);
- };
- TestInheritClassImpl<TDerivedNonVirtual>();
- }
-
- void TestInheritVirtualClass() {
- struct IInterface {
- virtual void Save(IOutputStream* out) const = 0;
- virtual void Load(IInputStream* in) = 0;
- };
- struct TBaseVirtual: IInterface {
- TString Str1;
- Y_SAVELOAD_DEFINE_OVERRIDE(Str1);
- };
- struct TDerivedVirtual: TBaseVirtual {
- TString Str2;
- TString Str3;
- Y_SAVELOAD_DEFINE_OVERRIDE(TNonVirtualSaver<TBaseVirtual>{this}, Str2, Str3);
- };
- TestInheritClassImpl<TDerivedVirtual>();
- TestInheritClassImpl<TDerivedVirtual, TBaseVirtual>();
- TestInheritClassImpl<TDerivedVirtual, IInterface>();
- }
+
+ // tests serialization of class with three public string members
+ template <class TDerived, class TInterface = TDerived>
+ void TestInheritClassImpl() {
+ TBufferStream s;
+ {
+ TDerived v1;
+ v1.Str1 = "One";
+ v1.Str2 = "Two";
+ v1.Str3 = "Three";
+ ::Save(&s, static_cast<const TInterface&>(v1));
+ }
+ {
+ TDerived v2;
+ ::Load(&s, static_cast<TInterface&>(v2));
+ UNIT_ASSERT_VALUES_EQUAL_C(v2.Str1, "One", TypeName<TDerived>() << " via " << TypeName<TInterface>());
+ UNIT_ASSERT_VALUES_EQUAL_C(v2.Str2, "Two", TypeName<TDerived>() << " via " << TypeName<TInterface>());
+ UNIT_ASSERT_VALUES_EQUAL_C(v2.Str3, "Three", TypeName<TDerived>() << " via " << TypeName<TInterface>());
+ }
+ }
+
+ void TestInheritNonVirtualClass() {
+ struct TBaseNonVirtual {
+ TString Str1;
+ Y_SAVELOAD_DEFINE(Str1);
+ };
+ struct TDerivedNonVirtual: TBaseNonVirtual {
+ TString Str2;
+ TString Str3;
+ Y_SAVELOAD_DEFINE(TNonVirtualSaver<TBaseNonVirtual>{this}, Str2, Str3);
+ };
+ TestInheritClassImpl<TDerivedNonVirtual>();
+ }
+
+ void TestInheritVirtualClass() {
+ struct IInterface {
+ virtual void Save(IOutputStream* out) const = 0;
+ virtual void Load(IInputStream* in) = 0;
+ };
+ struct TBaseVirtual: IInterface {
+ TString Str1;
+ Y_SAVELOAD_DEFINE_OVERRIDE(Str1);
+ };
+ struct TDerivedVirtual: TBaseVirtual {
+ TString Str2;
+ TString Str3;
+ Y_SAVELOAD_DEFINE_OVERRIDE(TNonVirtualSaver<TBaseVirtual>{this}, Str2, Str3);
+ };
+ TestInheritClassImpl<TDerivedVirtual>();
+ TestInheritClassImpl<TDerivedVirtual, TBaseVirtual>();
+ TestInheritClassImpl<TDerivedVirtual, IInterface>();
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TSaveLoadTest);