aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:46 +0300
commit8cbc307de0221f84c80c42dcbe07d40727537e2c (patch)
tree625d5a673015d1df891e051033e9fcde5c7be4e5 /util/generic
parent30d1ef3941e0dc835be7609de5ebee66958f215a (diff)
downloadydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/adaptor_ut.cpp10
-rw-r--r--util/generic/algorithm.h24
-rw-r--r--util/generic/algorithm_ut.cpp130
-rw-r--r--util/generic/array_ref.h20
-rw-r--r--util/generic/array_ref_ut.cpp48
-rw-r--r--util/generic/array_size.h2
-rw-r--r--util/generic/array_size_ut.cpp14
-rw-r--r--util/generic/benchmark/fastclp2/main.cpp90
-rw-r--r--util/generic/benchmark/fastclp2/metrics/main.py8
-rw-r--r--util/generic/benchmark/fastclp2/metrics/ya.make26
-rw-r--r--util/generic/benchmark/fastclp2/ya.make20
-rw-r--r--util/generic/benchmark/log2/main.cpp186
-rw-r--r--util/generic/benchmark/log2/metrics/main.py8
-rw-r--r--util/generic/benchmark/log2/metrics/ya.make26
-rw-r--r--util/generic/benchmark/log2/ya.make26
-rw-r--r--util/generic/benchmark/rotate_bits/main.cpp124
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/main.py8
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/ya.make26
-rw-r--r--util/generic/benchmark/rotate_bits/ya.make20
-rw-r--r--util/generic/benchmark/vector_count_ctor/f.cpp46
-rw-r--r--util/generic/benchmark/vector_count_ctor/f.h18
-rw-r--r--util/generic/benchmark/vector_count_ctor/main.cpp58
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/main.py8
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/ya.make26
-rw-r--r--util/generic/benchmark/vector_count_ctor/ya.make28
-rw-r--r--util/generic/benchmark/ya.make22
-rw-r--r--util/generic/bitmap.h80
-rw-r--r--util/generic/bitmap_ut.cpp38
-rw-r--r--util/generic/bitops.cpp276
-rw-r--r--util/generic/bitops.h620
-rw-r--r--util/generic/bitops_ut.cpp134
-rw-r--r--util/generic/buffer.cpp10
-rw-r--r--util/generic/buffer.h4
-rw-r--r--util/generic/buffer_ut.cpp20
-rw-r--r--util/generic/cast.h42
-rw-r--r--util/generic/cast_ut.cpp50
-rw-r--r--util/generic/explicit_type.h2
-rw-r--r--util/generic/explicit_type_ut.cpp4
-rw-r--r--util/generic/fastqueue.h2
-rw-r--r--util/generic/flags.cpp30
-rw-r--r--util/generic/flags.h22
-rw-r--r--util/generic/flags_ut.cpp12
-rw-r--r--util/generic/function_ut.cpp16
-rw-r--r--util/generic/fuzz/vector/main.cpp2
-rw-r--r--util/generic/fwd.h82
-rw-r--r--util/generic/guid.cpp8
-rw-r--r--util/generic/guid.h28
-rw-r--r--util/generic/guid_ut.cpp14
-rw-r--r--util/generic/hash.h54
-rw-r--r--util/generic/hash_primes_ut.cpp4
-rw-r--r--util/generic/hash_set.h2
-rw-r--r--util/generic/hash_ut.cpp94
-rw-r--r--util/generic/intrlist.h12
-rw-r--r--util/generic/intrlist_ut.cpp2
-rw-r--r--util/generic/is_in.h8
-rw-r--r--util/generic/is_in_ut.cpp12
-rw-r--r--util/generic/iterator.h8
-rw-r--r--util/generic/iterator_range_ut.cpp12
-rw-r--r--util/generic/iterator_ut.cpp8
-rw-r--r--util/generic/lazy_value.h2
-rw-r--r--util/generic/lazy_value_ut.cpp16
-rw-r--r--util/generic/list_ut.cpp4
-rw-r--r--util/generic/map_ut.cpp28
-rw-r--r--util/generic/mapfindptr.h4
-rw-r--r--util/generic/mapfindptr_ut.cpp14
-rw-r--r--util/generic/maybe.h8
-rw-r--r--util/generic/maybe_ut.cpp70
-rw-r--r--util/generic/mem_copy.h4
-rw-r--r--util/generic/mem_copy_ut.cpp16
-rw-r--r--util/generic/objects_counter_ut.cpp8
-rw-r--r--util/generic/ptr.h58
-rw-r--r--util/generic/ptr_ut.cpp34
-rw-r--r--util/generic/queue_ut.cpp18
-rw-r--r--util/generic/refcount.h2
-rw-r--r--util/generic/scope.h40
-rw-r--r--util/generic/scope_ut.cpp6
-rw-r--r--util/generic/set_ut.cpp24
-rw-r--r--util/generic/singleton.cpp8
-rw-r--r--util/generic/singleton.h2
-rw-r--r--util/generic/singleton_ut.cpp8
-rw-r--r--util/generic/stack_ut.cpp4
-rw-r--r--util/generic/strbase.h32
-rw-r--r--util/generic/strbuf.h14
-rw-r--r--util/generic/strbuf_ut.cpp82
-rw-r--r--util/generic/string.h2
-rw-r--r--util/generic/string_transparent_hash_ut.cpp20
-rw-r--r--util/generic/string_ut.cpp56
-rw-r--r--util/generic/string_ut.h24
-rw-r--r--util/generic/typelist.h10
-rw-r--r--util/generic/typelist_ut.cpp16
-rw-r--r--util/generic/typetraits.h108
-rw-r--r--util/generic/typetraits_ut.cpp76
-rw-r--r--util/generic/ut/ya.make22
-rw-r--r--util/generic/utility.h4
-rw-r--r--util/generic/va_args.cpp6
-rw-r--r--util/generic/va_args.h12
-rwxr-xr-xutil/generic/va_args_gen.py2
-rw-r--r--util/generic/va_args_ut.cpp10
-rw-r--r--util/generic/vector_ut.cpp2
-rw-r--r--util/generic/xrange.h56
-rw-r--r--util/generic/xrange_ut.cpp20
-rw-r--r--util/generic/yexception.cpp36
-rw-r--r--util/generic/yexception.h84
-rw-r--r--util/generic/yexception_ut.cpp36
-rw-r--r--util/generic/ylimits.h4
-rw-r--r--util/generic/ylimits_ut.cpp6
-rw-r--r--util/generic/ymath.cpp16
-rw-r--r--util/generic/ymath.h10
-rw-r--r--util/generic/ymath_ut.cpp4
109 files changed, 1941 insertions, 1941 deletions
diff --git a/util/generic/adaptor_ut.cpp b/util/generic/adaptor_ut.cpp
index 721f849f93..1a14b942b4 100644
--- a/util/generic/adaptor_ut.cpp
+++ b/util/generic/adaptor_ut.cpp
@@ -32,8 +32,8 @@ struct TState {
}
};
-Y_UNIT_TEST_SUITE(TReverseAdaptor) {
- Y_UNIT_TEST(ReadTest) {
+Y_UNIT_TEST_SUITE(TReverseAdaptor) {
+ Y_UNIT_TEST(ReadTest) {
TVector<int> cont = {1, 2, 3};
TVector<int> etalon = {3, 2, 1};
size_t idx = 0;
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
}
- Y_UNIT_TEST(WriteTest) {
+ Y_UNIT_TEST(WriteTest) {
TVector<int> cont = {1, 2, 3};
TVector<int> etalon = {3, 6, 9};
size_t idx = 0;
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
}
- Y_UNIT_TEST(InnerTypeTest) {
+ Y_UNIT_TEST(InnerTypeTest) {
using TStub = TVector<int>;
TStub stub;
const TStub cstub;
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
UNIT_ASSERT_TYPES_EQUAL(decltype(Reversed(cstub)), TReverseRange<const TStub&>);
}
- Y_UNIT_TEST(CopyMoveTest) {
+ Y_UNIT_TEST(CopyMoveTest) {
TState lvalue;
const TState clvalue;
UNIT_ASSERT_NO_EXCEPTION(Reversed(lvalue));
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index badfb88993..fce4c9c695 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -181,7 +181,7 @@ static inline bool AnyOf(const C& c, P pred) {
template <class I, class P>
static inline auto FindIfPtr(I f, I l, P pred) -> decltype(&*f) {
I found = FindIf(f, l, pred);
- return (found != l) ? &*found : nullptr;
+ return (found != l) ? &*found : nullptr;
}
template <class C, class P>
@@ -218,16 +218,16 @@ inline bool EqualToOneOf(const T& x, const U& y, const Other&... other) {
return x == y || EqualToOneOf(x, other...);
}
-template <typename T>
-static inline size_t CountOf(const T&) {
- return 0;
-}
-
-template <typename T, typename U, typename... Other>
-static inline size_t CountOf(const T& x, const U& y, const Other&... other) {
- return static_cast<size_t>(x == y) + CountOf(x, other...);
-}
-
+template <typename T>
+static inline size_t CountOf(const T&) {
+ return 0;
+}
+
+template <typename T, typename U, typename... Other>
+static inline size_t CountOf(const T& x, const U& y, const Other&... other) {
+ return static_cast<size_t>(x == y) + CountOf(x, other...);
+}
+
template <class I>
static inline void PushHeap(I f, I l) {
std::push_heap(f, l);
@@ -438,7 +438,7 @@ static inline void Fill(I f, I l, const T& v) {
std::fill(f, l, v);
}
-template <typename I, typename S, typename T>
+template <typename I, typename S, typename T>
static inline I FillN(I f, S n, const T& v) {
return std::fill_n(f, n, v);
}
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 8d732fcc0c..fc2a05efb9 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -6,8 +6,8 @@
static auto isOne = [](char c) { return c == '1'; };
-Y_UNIT_TEST_SUITE(TAlgorithm) {
- Y_UNIT_TEST(AnyTest) {
+Y_UNIT_TEST_SUITE(TAlgorithm) {
+ Y_UNIT_TEST(AnyTest) {
UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne));
UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne));
UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne));
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(1 == AnyOf(array01, isOne));
}
- Y_UNIT_TEST(AllOfTest) {
+ Y_UNIT_TEST(AllOfTest) {
UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne));
UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne));
UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne));
@@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(1 == AllOf(array11, isOne));
}
- Y_UNIT_TEST(CountIfTest) {
+ Y_UNIT_TEST(CountIfTest) {
UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne));
UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne));
UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne));
@@ -68,40 +68,40 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
void operator=(const TStrokaNoCopy&);
};
- Y_UNIT_TEST(CountOfTest) {
- UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2);
-
- // Checking comparison of different types.
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2);
-
+ Y_UNIT_TEST(CountOfTest) {
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2);
+
+ // Checking comparison of different types.
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2);
+
// TString and const char *
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi"), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1);
-
+
// TString and TStringBuf
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"),
TStringBuf("xyz")),
1);
-
- // TStringBuf and const char *
+
+ // TStringBuf and const char *
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1);
-
+
// TStringBuf and TString
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"),
TString("xyz")),
1);
- }
-
- Y_UNIT_TEST(EqualToOneOfTest) {
+ }
+
+ Y_UNIT_TEST(EqualToOneOfTest) {
UNIT_ASSERT(1 == EqualToOneOf(1, 1, 2));
UNIT_ASSERT(1 == EqualToOneOf(2, 1, 2));
UNIT_ASSERT(0 == EqualToOneOf(3, 1, 2));
@@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
template <class TTestConstPtr>
void TestFindIfPtrFoundValue(int j, TTestConstPtr root) {
if (j == 3) {
- UNIT_ASSERT(root == nullptr);
+ UNIT_ASSERT(root == nullptr);
} else if (j == 4) {
UNIT_ASSERT(root && *root == 2);
} else {
@@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(FindIndexTest) {
+ Y_UNIT_TEST(FindIndexTest) {
TVectorNoCopy v;
v.push_back(1);
v.push_back(2);
@@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(NPOS, FindIndexIf(empty, [](int x) { return x == 3; }));
}
- Y_UNIT_TEST(SortUniqueTest) {
+ Y_UNIT_TEST(SortUniqueTest) {
{
TVector<TString> v;
SortUnique(v);
@@ -266,21 +266,21 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(EraseTest) {
+ Y_UNIT_TEST(EraseTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {5, 4, 2, 1, 0};
Erase(data, 3);
UNIT_ASSERT_EQUAL(data, expected);
}
- Y_UNIT_TEST(EraseIfTest) {
+ Y_UNIT_TEST(EraseIfTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {2, 1, 0};
EraseIf(data, [](int i) { return i >= 3; });
UNIT_ASSERT_EQUAL(data, expected);
}
- Y_UNIT_TEST(EraseNodesIfTest) {
+ Y_UNIT_TEST(EraseNodesIfTest) {
TMap<int, int> map{{1, 1}, {2, 2}, {3, 5}};
TMap<int, int> expectedMap{{1, 1}};
EraseNodesIf(map, [](auto p) { return p.first >= 2; });
@@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(hashMultiMap, expectedHashMultiMap);
}
- Y_UNIT_TEST(NthElementTest) {
+ Y_UNIT_TEST(NthElementTest) {
{
TVector<TString> v;
NthElement(v.begin(), v.begin(), v.end());
@@ -348,7 +348,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(BinarySearchTest) {
+ Y_UNIT_TEST(BinarySearchTest) {
{
TVector<TString> v;
bool test = BinarySearch(v.begin(), v.end(), "test");
@@ -358,10 +358,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
{
int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2);
+ bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2);
UNIT_ASSERT_EQUAL(test, true);
- test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10);
+ test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10);
UNIT_ASSERT_EQUAL(test, false);
}
@@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(EqualRangeTest) {
+ Y_UNIT_TEST(EqualRangeTest) {
{
TVector<TString> v;
using PairOfVector = std::pair<TVector<TString>::iterator, TVector<TString>::iterator>;
@@ -392,11 +392,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
{
int data[] = {1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 5};
using PairOfInt = std::pair<int*, int*>;
- PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3);
+ PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3);
UNIT_ASSERT_EQUAL(tmp.second - tmp.first, 4);
UNIT_ASSERT_EQUAL(tmp.first - data, 7);
- UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2);
+ UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2);
}
{
@@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(IsSortedTest) {
+ Y_UNIT_TEST(IsSortedTest) {
TVector<int> v0;
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v0.begin(), v0.end()), true);
@@ -445,91 +445,91 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v3.begin(), v3.end(), std::negate<int>()), false);
}
- Y_UNIT_TEST(SortTestTwoIterators) {
+ Y_UNIT_TEST(SortTestTwoIterators) {
TVector<int> collection = {10, 2, 7};
Sort(collection.begin(), collection.end());
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) {
+ Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) {
TVector<int> collection = {10, 2, 7};
Sort(collection.begin(), collection.end(), [](int l, int r) { return l > r; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestContainer) {
+ Y_UNIT_TEST(SortTestContainer) {
TVector<int> collection = {10, 2, 7};
Sort(collection);
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestContainerAndComparator) {
+ Y_UNIT_TEST(SortTestContainerAndComparator) {
TVector<int> collection = {10, 2, 7};
Sort(collection, [](int l, int r) { return l > r; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestTwoIterators) {
+ Y_UNIT_TEST(StableSortTestTwoIterators) {
TVector<int> collection = {10, 2, 7};
StableSort(collection.begin(), collection.end());
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) {
+ Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSort(collection.begin(), collection.end(), [](int l, int r) { return (l / 100) < (r / 100); });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestContainer) {
+ Y_UNIT_TEST(StableSortTestContainer) {
TVector<int> collection = {10, 2, 7};
StableSort(collection);
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestContainerAndComparator) {
+ Y_UNIT_TEST(StableSortTestContainerAndComparator) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSort(collection, [](int l, int r) { return (l / 100) < (r / 100); });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortByTest) {
+ Y_UNIT_TEST(SortByTest) {
TVector<int> collection = {10, 2, 7};
SortBy(collection, [](int x) { return -x; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortByTest) {
+ Y_UNIT_TEST(StableSortByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortUniqueByTest) {
+ Y_UNIT_TEST(SortUniqueByTest) {
TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortUniqueByTest) {
+ Y_UNIT_TEST(StableSortUniqueByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(IotaTest) {
+ Y_UNIT_TEST(IotaTest) {
TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
@@ -543,7 +543,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(v[9], 9);
}
- Y_UNIT_TEST(CopyNTest) {
+ Y_UNIT_TEST(CopyNTest) {
int data[] = {1, 2, 3, 4, 8, 7, 6, 5};
const size_t vSize = 10;
TVector<int> result(10, 0);
@@ -575,7 +575,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(CopyIfTest) {
+ Y_UNIT_TEST(CopyIfTest) {
const size_t count = 9;
int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
const size_t vSize = 10;
@@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(MinMaxElementTest) {
+ Y_UNIT_TEST(MinMaxElementTest) {
TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).first, 0);
@@ -602,7 +602,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).second, 11);
}
- Y_UNIT_TEST(MinMaxTest) {
+ Y_UNIT_TEST(MinMaxTest) {
std::pair<int, int> p1 = MinMax(5, 12);
UNIT_ASSERT_EQUAL(p1.first, 5);
UNIT_ASSERT_EQUAL(p1.second, 12);
@@ -612,7 +612,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(p2.second, TString("test"));
}
- Y_UNIT_TEST(TestMaxElementBy) {
+ Y_UNIT_TEST(TestMaxElementBy) {
const int array[] = {1, 2, 5, 3, 4, 5};
UNIT_ASSERT_VALUES_EQUAL(*MaxElementBy(array, [](int x) {
return x * x;
@@ -638,7 +638,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_STRINGS_EQUAL(*MaxElementBy(strings, [](TString s) { return s.size(); }), "three");
}
- Y_UNIT_TEST(TestMinElementBy) {
+ Y_UNIT_TEST(TestMinElementBy) {
const int array[] = {2, 3, 4, 1, 5};
UNIT_ASSERT_VALUES_EQUAL(*MinElementBy(array, [](int x) -> char {
return 'a' + x;
@@ -668,12 +668,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_STRINGS_EQUAL(*MinElementBy(strings.rbegin(), strings.rend(), stringLength), "two");
}
- Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) {
+ Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) {
const TVector<int> empty;
UNIT_ASSERT_EQUAL(MaxElementBy(empty, [](int) { return 0; }), empty.end());
}
- Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) {
+ Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) {
const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
@@ -682,12 +682,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
MaxElementBy(empty, functor);
}
- Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) {
+ Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) {
const TVector<int> empty;
UNIT_ASSERT_EQUAL(MinElementBy(empty, [](int) { return 0; }), empty.end());
}
- Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) {
+ Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) {
const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
@@ -756,7 +756,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(FindIfForContainer) {
+ Y_UNIT_TEST(FindIfForContainer) {
using std::begin;
using std::end;
@@ -790,14 +790,14 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
return &r + 1;
}
- Y_UNIT_TEST(FindIfForUserType) {
+ Y_UNIT_TEST(FindIfForUserType) {
// Compileability test. Should work for user types with begin/end overloads
TRange range;
auto i = FindIf(range, [](auto) { return false; });
Y_UNUSED(i);
}
- Y_UNIT_TEST(TestLowerBoundBy) {
+ Y_UNIT_TEST(TestLowerBoundBy) {
using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
@@ -817,7 +817,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL((it + 1)->second, 4);
}
- Y_UNIT_TEST(TestUpperBoundBy) {
+ Y_UNIT_TEST(TestUpperBoundBy) {
using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
@@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT((it + 1) == data.end());
}
- Y_UNIT_TEST(TestFindInContainer) {
+ Y_UNIT_TEST(TestFindInContainer) {
std::vector<int> v = {1, 2, 1000, 15, 100};
UNIT_ASSERT(Find(v, 5) == v.end());
UNIT_ASSERT(Find(v, 1) == v.begin());
diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h
index 1ac60ac7d3..ae3eff8e19 100644
--- a/util/generic/array_ref.h
+++ b/util/generic/array_ref.h
@@ -259,16 +259,16 @@ constexpr TArrayRef<typename Range::value_type> MakeArrayRef(Range& range) {
return TArrayRef<typename Range::value_type>(range);
}
-template <class Range>
-constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) {
- return TArrayRef<const typename Range::value_type>(range);
-}
-
-template <class Range>
-constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) {
- return TArrayRef<const typename Range::value_type>(range);
-}
-
+template <class Range>
+constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) {
+ return TArrayRef<const typename Range::value_type>(range);
+}
+
+template <class Range>
+constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) {
+ return TArrayRef<const typename Range::value_type>(range);
+}
+
template <class T>
constexpr TArrayRef<T> MakeArrayRef(T* data, size_t size) {
return TArrayRef<T>(data, size);
diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp
index 4c8eaf7135..33ae908a71 100644
--- a/util/generic/array_ref_ut.cpp
+++ b/util/generic/array_ref_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestArrayRef) {
+Y_UNIT_TEST_SUITE(TestArrayRef) {
Y_UNIT_TEST(TestDefaultConstructor) {
TArrayRef<int> defaulted;
UNIT_ASSERT_VALUES_EQUAL(defaulted.data(), nullptr);
@@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
UNIT_ASSERT_EQUAL(aRef.subspan(1, 3), MakeArrayRef(std::vector<int>{2, 3, 4}));
}
- Y_UNIT_TEST(TestSlice) {
+ Y_UNIT_TEST(TestSlice) {
const int a0[] = {1, 2, 3};
TArrayRef<const int> r0(a0);
TArrayRef<const int> s0 = r0.Slice(2);
@@ -278,7 +278,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
a[0] = 8;
}
- Y_UNIT_TEST(TestConst) {
+ Y_UNIT_TEST(TestConst) {
int a[] = {1, 2};
Do(a);
UNIT_ASSERT_VALUES_EQUAL(a[0], 8);
@@ -298,25 +298,25 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
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>) {
- // noop
- }
-
- Y_UNIT_TEST(TestMakeConstArrayRef) {
- TVector<int> data;
-
- // Won't compile because can't deduce `T` for `Foo`
- // Foo(data);
-
- // Won't compile because again can't deduce `T` for `Foo`
- // Foo(MakeArrayRef(data));
-
- // Success!
- Foo(MakeConstArrayRef(data));
-
- const TVector<int> constData;
- Foo(MakeConstArrayRef(constData));
- }
+
+ template <typename T>
+ static void Foo(const TConstArrayRef<T>) {
+ // noop
+ }
+
+ Y_UNIT_TEST(TestMakeConstArrayRef) {
+ TVector<int> data;
+
+ // Won't compile because can't deduce `T` for `Foo`
+ // Foo(data);
+
+ // Won't compile because again can't deduce `T` for `Foo`
+ // Foo(MakeArrayRef(data));
+
+ // Success!
+ Foo(MakeConstArrayRef(data));
+
+ const TVector<int> constData;
+ Foo(MakeConstArrayRef(constData));
+ }
}
diff --git a/util/generic/array_size.h b/util/generic/array_size.h
index 4d5f18ce63..a56944b4ae 100644
--- a/util/generic/array_size.h
+++ b/util/generic/array_size.h
@@ -21,4 +21,4 @@ namespace NArraySizePrivate {
};
}
-#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result)
+#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result)
diff --git a/util/generic/array_size_ut.cpp b/util/generic/array_size_ut.cpp
index 13f45903c5..b3243425a9 100644
--- a/util/generic/array_size_ut.cpp
+++ b/util/generic/array_size_ut.cpp
@@ -2,21 +2,21 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ArraySizeTest) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(ArraySizeTest) {
+ Y_UNIT_TEST(Test1) {
int x[100];
- Y_UNUSED(x); /* Make MSVC happy. */
+ Y_UNUSED(x); /* Make MSVC happy. */
- UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100);
+ UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100);
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
struct T {
};
T x[1];
- Y_UNUSED(x); /* Make MSVC happy. */
+ Y_UNUSED(x); /* Make MSVC happy. */
- UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1);
+ UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1);
}
}
diff --git a/util/generic/benchmark/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp
index 49277db077..69bf1dc960 100644
--- a/util/generic/benchmark/fastclp2/main.cpp
+++ b/util/generic/benchmark/fastclp2/main.cpp
@@ -1,50 +1,50 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/bitops.h>
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-#include <util/generic/singleton.h>
-
-#include <util/random/fast.h>
-
-namespace {
- template <typename T, size_t N>
- struct TExamplesHolder {
- TExamplesHolder()
+
+#include <util/generic/bitops.h>
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+#include <util/generic/singleton.h>
+
+#include <util/random/fast.h>
+
+namespace {
+ template <typename T, size_t N>
+ struct TExamplesHolder {
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{42u * sizeof(T) * N};
- for (auto& x : Examples) {
- x = prng();
- }
- }
-
+ TFastRng<ui64> prng{42u * sizeof(T) * N};
+ for (auto& x : Examples) {
+ x = prng();
+ }
+ }
+
TVector<T> Examples;
- };
-}
-
+ };
+}
+
#define DEFINE_BENCHMARK(type, count) \
- Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \
- } \
- } \
- }
-
-DEFINE_BENCHMARK(ui8, 1)
-DEFINE_BENCHMARK(ui8, 10)
-DEFINE_BENCHMARK(ui8, 100)
-DEFINE_BENCHMARK(ui16, 1)
-DEFINE_BENCHMARK(ui16, 10)
-DEFINE_BENCHMARK(ui16, 100)
-DEFINE_BENCHMARK(ui32, 1)
-DEFINE_BENCHMARK(ui32, 10)
-DEFINE_BENCHMARK(ui32, 100)
-DEFINE_BENCHMARK(ui64, 1)
-DEFINE_BENCHMARK(ui64, 10)
-DEFINE_BENCHMARK(ui64, 100)
-
-#undef DEFINE_BENCHMARKS
+ Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \
+ } \
+ } \
+ }
+
+DEFINE_BENCHMARK(ui8, 1)
+DEFINE_BENCHMARK(ui8, 10)
+DEFINE_BENCHMARK(ui8, 100)
+DEFINE_BENCHMARK(ui16, 1)
+DEFINE_BENCHMARK(ui16, 10)
+DEFINE_BENCHMARK(ui16, 100)
+DEFINE_BENCHMARK(ui32, 1)
+DEFINE_BENCHMARK(ui32, 10)
+DEFINE_BENCHMARK(ui32, 100)
+DEFINE_BENCHMARK(ui64, 1)
+DEFINE_BENCHMARK(ui64, 10)
+DEFINE_BENCHMARK(ui64, 100)
+
+#undef DEFINE_BENCHMARKS
diff --git a/util/generic/benchmark/fastclp2/metrics/main.py b/util/generic/benchmark/fastclp2/metrics/main.py
index 5573c6a5d7..4baa3fe256 100644
--- a/util/generic/benchmark/fastclp2/metrics/main.py
+++ b/util/generic/benchmark/fastclp2/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/fastclp2/fastclp2', threads=8))
diff --git a/util/generic/benchmark/fastclp2/metrics/ya.make b/util/generic/benchmark/fastclp2/metrics/ya.make
index b2d17ebad3..9411e3d5d5 100644
--- a/util/generic/benchmark/fastclp2/metrics/ya.make
+++ b/util/generic/benchmark/fastclp2/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/fastclp2)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/fastclp2/ya.make b/util/generic/benchmark/fastclp2/ya.make
index 976977014f..a475d0c67f 100644
--- a/util/generic/benchmark/fastclp2/ya.make
+++ b/util/generic/benchmark/fastclp2/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp
index 969f09a309..a5490aba67 100644
--- a/util/generic/benchmark/log2/main.cpp
+++ b/util/generic/benchmark/log2/main.cpp
@@ -1,30 +1,30 @@
#include <library/cpp/testing/benchmark/bench.h>
-
+
#include <library/cpp/fast_log/fast_log.h>
-
-#include <util/generic/singleton.h>
-#include <util/generic/vector.h>
-#include <util/random/fast.h>
-#include <util/generic/xrange.h>
-
-#include <cmath>
-namespace {
- template <typename T, size_t N>
- struct TExamplesHolder {
+
+#include <util/generic/singleton.h>
+#include <util/generic/vector.h>
+#include <util/random/fast.h>
+#include <util/generic/xrange.h>
+
+#include <cmath>
+namespace {
+ template <typename T, size_t N>
+ struct TExamplesHolder {
TVector<T> Examples;
-
- TExamplesHolder()
+
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{N * 42};
- for (auto& x : Examples) {
- x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number
- }
- }
- };
-}
-
-#define DEFINE_BENCHMARK(type, count) \
+ TFastRng<ui64> prng{N * 42};
+ for (auto& x : Examples) {
+ x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number
+ }
+ }
+ };
+}
+
+#define DEFINE_BENCHMARK(type, count) \
Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \
const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
for (const auto i : xrange(iface.Iterations())) { \
@@ -44,64 +44,64 @@ namespace {
} \
} \
} \
- Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \
- } \
- } \
- } \
- \
+ Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \
+ } \
+ } \
+ } \
+ \
Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \
- } \
- } \
+ } \
+ } \
} \
\
Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \
@@ -122,19 +122,19 @@ namespace {
Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \
} \
} \
- }
-
-DEFINE_BENCHMARK(float, 1)
-DEFINE_BENCHMARK(float, 2)
-DEFINE_BENCHMARK(float, 4)
-DEFINE_BENCHMARK(float, 8)
-DEFINE_BENCHMARK(float, 16)
-DEFINE_BENCHMARK(float, 32)
-DEFINE_BENCHMARK(float, 64)
-DEFINE_BENCHMARK(float, 128)
-DEFINE_BENCHMARK(float, 256)
-DEFINE_BENCHMARK(float, 1024)
-DEFINE_BENCHMARK(float, 2048)
-DEFINE_BENCHMARK(float, 4096)
-
-#undef DEFINE_BENCHMARK
+ }
+
+DEFINE_BENCHMARK(float, 1)
+DEFINE_BENCHMARK(float, 2)
+DEFINE_BENCHMARK(float, 4)
+DEFINE_BENCHMARK(float, 8)
+DEFINE_BENCHMARK(float, 16)
+DEFINE_BENCHMARK(float, 32)
+DEFINE_BENCHMARK(float, 64)
+DEFINE_BENCHMARK(float, 128)
+DEFINE_BENCHMARK(float, 256)
+DEFINE_BENCHMARK(float, 1024)
+DEFINE_BENCHMARK(float, 2048)
+DEFINE_BENCHMARK(float, 4096)
+
+#undef DEFINE_BENCHMARK
diff --git a/util/generic/benchmark/log2/metrics/main.py b/util/generic/benchmark/log2/metrics/main.py
index 26f6b57812..873f17664c 100644
--- a/util/generic/benchmark/log2/metrics/main.py
+++ b/util/generic/benchmark/log2/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/log2/log2', threads=8))
diff --git a/util/generic/benchmark/log2/metrics/ya.make b/util/generic/benchmark/log2/metrics/ya.make
index eb987e38d2..5afd7de200 100644
--- a/util/generic/benchmark/log2/metrics/ya.make
+++ b/util/generic/benchmark/log2/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/log2)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/log2/ya.make b/util/generic/benchmark/log2/ya.make
index 45d751909e..eeef80523b 100644
--- a/util/generic/benchmark/log2/ya.make
+++ b/util/generic/benchmark/log2/ya.make
@@ -1,17 +1,17 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-PEERDIR(
+
+SRCS(
+ main.cpp
+)
+
+PEERDIR(
library/cpp/fast_log
-)
-
-END()
+)
+
+END()
diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp
index 057edbe864..929d2c4ca9 100644
--- a/util/generic/benchmark/rotate_bits/main.cpp
+++ b/util/generic/benchmark/rotate_bits/main.cpp
@@ -1,66 +1,66 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-#include <util/generic/singleton.h>
-
-#include <util/random/fast.h>
-
-namespace {
- template <typename T>
- struct TExample {
- T Value;
- ui8 Shift;
- };
-
- template <typename T, size_t N>
- struct TExamplesHolder {
- TExamplesHolder()
+
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+#include <util/generic/singleton.h>
+
+#include <util/random/fast.h>
+
+namespace {
+ template <typename T>
+ struct TExample {
+ T Value;
+ ui8 Shift;
+ };
+
+ template <typename T, size_t N>
+ struct TExamplesHolder {
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{42u * sizeof(T) * N};
- for (auto& e : Examples) {
- e.Value = prng();
- e.Shift = prng() % (8 * sizeof(T));
- }
- }
-
+ TFastRng<ui64> prng{42u * sizeof(T) * N};
+ for (auto& e : Examples) {
+ e.Value = prng();
+ e.Shift = prng() % (8 * sizeof(T));
+ }
+ }
+
TVector<TExample<T>> Examples;
- };
-}
-
-#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \
- Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \
- } \
- } \
- }
-
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100)
-
-#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES
+ };
+}
+
+#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \
+ Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \
+ } \
+ } \
+ }
+
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100)
+
+#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES
diff --git a/util/generic/benchmark/rotate_bits/metrics/main.py b/util/generic/benchmark/rotate_bits/metrics/main.py
index b30555775f..d752885779 100644
--- a/util/generic/benchmark/rotate_bits/metrics/main.py
+++ b/util/generic/benchmark/rotate_bits/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/rotate_bits/rotate_bits', threads=8))
diff --git a/util/generic/benchmark/rotate_bits/metrics/ya.make b/util/generic/benchmark/rotate_bits/metrics/ya.make
index ac27d2f845..3bef9fae8a 100644
--- a/util/generic/benchmark/rotate_bits/metrics/ya.make
+++ b/util/generic/benchmark/rotate_bits/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/rotate_bits)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/rotate_bits/ya.make b/util/generic/benchmark/rotate_bits/ya.make
index 976977014f..a475d0c67f 100644
--- a/util/generic/benchmark/rotate_bits/ya.make
+++ b/util/generic/benchmark/rotate_bits/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/vector_count_ctor/f.cpp b/util/generic/benchmark/vector_count_ctor/f.cpp
index b89e351ba7..e5d0a2ba25 100644
--- a/util/generic/benchmark/vector_count_ctor/f.cpp
+++ b/util/generic/benchmark/vector_count_ctor/f.cpp
@@ -1,25 +1,25 @@
-#include "f.h"
-
+#include "f.h"
+
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/vector.h>
-#include <util/generic/ptr.h>
-
-void CreateYvector(const size_t size, const size_t count) {
- for (size_t i = 0; i < count; ++i) {
- NBench::Clobber();
+
+#include <util/generic/vector.h>
+#include <util/generic/ptr.h>
+
+void CreateYvector(const size_t size, const size_t count) {
+ for (size_t i = 0; i < count; ++i) {
+ NBench::Clobber();
TVector<ui8> v(size);
- NBench::Escape(v.data());
- NBench::Clobber();
- }
-}
-
-void CreateCarray(const size_t size, const size_t count) {
- for (size_t i = 0; i < count; ++i) {
- NBench::Clobber();
- TArrayHolder<ui8> v(new ui8[size]);
- memset(v.Get(), 0, size * sizeof(ui8));
- NBench::Escape(v.Get());
- NBench::Clobber();
- }
-}
+ NBench::Escape(v.data());
+ NBench::Clobber();
+ }
+}
+
+void CreateCarray(const size_t size, const size_t count) {
+ for (size_t i = 0; i < count; ++i) {
+ NBench::Clobber();
+ TArrayHolder<ui8> v(new ui8[size]);
+ memset(v.Get(), 0, size * sizeof(ui8));
+ NBench::Escape(v.Get());
+ NBench::Clobber();
+ }
+}
diff --git a/util/generic/benchmark/vector_count_ctor/f.h b/util/generic/benchmark/vector_count_ctor/f.h
index a568341a45..c0b9e48803 100644
--- a/util/generic/benchmark/vector_count_ctor/f.h
+++ b/util/generic/benchmark/vector_count_ctor/f.h
@@ -1,9 +1,9 @@
-#pragma once
-
-#include <cstddef>
-
-// functions are declared in a separate translation unit so that compiler won't be able to see the
-// value of `size` during compilation.
-
-void CreateYvector(const size_t size, const size_t count);
-void CreateCarray(const size_t size, const size_t count);
+#pragma once
+
+#include <cstddef>
+
+// functions are declared in a separate translation unit so that compiler won't be able to see the
+// value of `size` during compilation.
+
+void CreateYvector(const size_t size, const size_t count);
+void CreateCarray(const size_t size, const size_t count);
diff --git a/util/generic/benchmark/vector_count_ctor/main.cpp b/util/generic/benchmark/vector_count_ctor/main.cpp
index 6fb1fda9c9..715186b40a 100644
--- a/util/generic/benchmark/vector_count_ctor/main.cpp
+++ b/util/generic/benchmark/vector_count_ctor/main.cpp
@@ -1,30 +1,30 @@
-#include "f.h"
-
+#include "f.h"
+
#include <library/cpp/testing/benchmark/bench.h>
-
-#define DEFINE_BENCHMARK(N) \
- Y_CPU_BENCHMARK(Yvector_##N, iface) { \
- CreateYvector(N, iface.Iterations()); \
- } \
- Y_CPU_BENCHMARK(Carray_##N, iface) { \
- CreateCarray(N, iface.Iterations()); \
- }
-
-DEFINE_BENCHMARK(1)
-DEFINE_BENCHMARK(2)
-DEFINE_BENCHMARK(8)
-DEFINE_BENCHMARK(10)
-DEFINE_BENCHMARK(16)
-DEFINE_BENCHMARK(20)
-DEFINE_BENCHMARK(1000)
-DEFINE_BENCHMARK(1024)
-DEFINE_BENCHMARK(8192)
-DEFINE_BENCHMARK(10000)
-DEFINE_BENCHMARK(65536)
-DEFINE_BENCHMARK(100000)
-DEFINE_BENCHMARK(4194304)
-DEFINE_BENCHMARK(1000000)
-DEFINE_BENCHMARK(33554432)
-DEFINE_BENCHMARK(10000000)
-DEFINE_BENCHMARK(268435456)
-DEFINE_BENCHMARK(100000000)
+
+#define DEFINE_BENCHMARK(N) \
+ Y_CPU_BENCHMARK(Yvector_##N, iface) { \
+ CreateYvector(N, iface.Iterations()); \
+ } \
+ Y_CPU_BENCHMARK(Carray_##N, iface) { \
+ CreateCarray(N, iface.Iterations()); \
+ }
+
+DEFINE_BENCHMARK(1)
+DEFINE_BENCHMARK(2)
+DEFINE_BENCHMARK(8)
+DEFINE_BENCHMARK(10)
+DEFINE_BENCHMARK(16)
+DEFINE_BENCHMARK(20)
+DEFINE_BENCHMARK(1000)
+DEFINE_BENCHMARK(1024)
+DEFINE_BENCHMARK(8192)
+DEFINE_BENCHMARK(10000)
+DEFINE_BENCHMARK(65536)
+DEFINE_BENCHMARK(100000)
+DEFINE_BENCHMARK(4194304)
+DEFINE_BENCHMARK(1000000)
+DEFINE_BENCHMARK(33554432)
+DEFINE_BENCHMARK(10000000)
+DEFINE_BENCHMARK(268435456)
+DEFINE_BENCHMARK(100000000)
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/main.py b/util/generic/benchmark/vector_count_ctor/metrics/main.py
index 835b44fe5f..f2602ed3ff 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/main.py
+++ b/util/generic/benchmark/vector_count_ctor/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/vector_count_ctor/vector_count_ctor', threads=8))
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/ya.make b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
index c48f89b564..1441bcbf3a 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/vector_count_ctor)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/vector_count_ctor/ya.make b/util/generic/benchmark/vector_count_ctor/ya.make
index 42ce442819..735d8cf397 100644
--- a/util/generic/benchmark/vector_count_ctor/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/ya.make
@@ -1,16 +1,16 @@
-OWNER(
- yazevnul
- g:util
-)
+OWNER(
+ yazevnul
+ g:util
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-ALLOCATOR(B)
-
-SRCS(
- main.cpp
- f.cpp
-)
-
-END()
+
+ALLOCATOR(B)
+
+SRCS(
+ main.cpp
+ f.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/ya.make b/util/generic/benchmark/ya.make
index 635860a646..9c18713826 100644
--- a/util/generic/benchmark/ya.make
+++ b/util/generic/benchmark/ya.make
@@ -1,19 +1,19 @@
OWNER(yazevnul g:util)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- fastclp2
- fastclp2/metrics
- log2
- log2/metrics
- rotate_bits
- rotate_bits/metrics
- singleton
+
+RECURSE(
+ fastclp2
+ fastclp2/metrics
+ log2
+ log2/metrics
+ rotate_bits
+ rotate_bits/metrics
+ singleton
smart_pointers
sort
string
- vector_count_ctor
+ vector_count_ctor
vector_count_ctor/metrics
cont_speed
-)
+)
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index f77d182460..dde9873936 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -31,12 +31,12 @@ namespace NBitMapPrivate {
template <typename TChunkType, size_t ExtraBits>
struct TSanitizeMask {
- static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits);
+ static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits);
};
template <typename TChunkType>
struct TSanitizeMask<TChunkType, 0> {
- static constexpr TChunkType Value = (TChunkType)~TChunkType(0u);
+ static constexpr TChunkType Value = (TChunkType)~TChunkType(0u);
};
template <typename TTargetChunk, typename TSourceChunk>
@@ -44,7 +44,7 @@ namespace NBitMapPrivate {
static_assert(sizeof(TTargetChunk) < sizeof(TSourceChunk), "expect sizeof(TTargetChunk) < sizeof(TSourceChunk)");
static_assert(0 == sizeof(TSourceChunk) % sizeof(TTargetChunk), "expect 0 == sizeof(TSourceChunk) % sizeof(TTargetChunk)");
- static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk);
+ static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk);
union TCnv {
TSourceChunk BigData;
@@ -55,14 +55,14 @@ namespace NBitMapPrivate {
TCnv c;
c.BigData = source;
#if defined(_big_endian_)
- ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
+ ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
#else
- ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
+ ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
#endif
}
static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE);
+ Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE);
if (targetSize > sourceSize * BLOCK_SIZE) {
::Fill(target + sourceSize * BLOCK_SIZE, target + targetSize, 0);
}
@@ -77,7 +77,7 @@ namespace NBitMapPrivate {
static_assert(sizeof(TTargetChunk) > sizeof(TSourceChunk), "expect sizeof(TTargetChunk) > sizeof(TSourceChunk)");
static_assert(0 == sizeof(TTargetChunk) % sizeof(TSourceChunk), "expect 0 == sizeof(TTargetChunk) % sizeof(TSourceChunk)");
- static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk);
+ static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk);
union TCnv {
TSourceChunk SmallData[BLOCK_SIZE];
@@ -95,7 +95,7 @@ namespace NBitMapPrivate {
}
static inline TTargetChunk CopyPartChunk(const TSourceChunk* source, size_t count) {
- Y_ASSERT(count <= BLOCK_SIZE);
+ Y_ASSERT(count <= BLOCK_SIZE);
TCnv c;
c.BigData = 0;
#if defined(_big_endian_)
@@ -107,7 +107,7 @@ namespace NBitMapPrivate {
}
static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize);
+ Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize);
if (targetSize * BLOCK_SIZE > sourceSize) {
::Fill(target + sourceSize / BLOCK_SIZE, target + targetSize, 0);
}
@@ -124,7 +124,7 @@ namespace NBitMapPrivate {
template <typename TChunk>
struct TUniformDataCopier {
static inline void Copy(TChunk* target, size_t targetSize, const TChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize >= sourceSize);
+ Y_ASSERT(targetSize >= sourceSize);
for (size_t i = 0; i < sourceSize; ++i) {
target[i] = source[i];
}
@@ -142,7 +142,7 @@ namespace NBitMapPrivate {
};
template <typename TTargetChunk, typename TSourceChunk>
- struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> {
+ struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> {
};
template <typename TTargetChunk, typename TSourceChunk>
@@ -154,7 +154,7 @@ namespace NBitMapPrivate {
struct TFixedStorage {
using TChunk = TChunkType;
- static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk));
+ static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk));
TChunk Data[Size];
@@ -170,7 +170,7 @@ namespace NBitMapPrivate {
template <typename TOtherChunk>
TFixedStorage(const TOtherChunk* data, size_t size) {
- Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity");
+ Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity");
CopyData(Data, Size, data, size);
}
@@ -180,16 +180,16 @@ namespace NBitMapPrivate {
}
}
- Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept {
+ Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept {
return BitCount;
}
- Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept {
+ Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept {
return Size;
}
// Returns true if the resulting storage capacity is enough to fit the requested size
- Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept {
+ Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept {
return bitSize <= BitCount;
}
@@ -286,12 +286,12 @@ namespace NBitMapPrivate {
template <size_t num>
struct TDivCount {
- static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value;
+ static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value;
};
template <>
struct TDivCount<0> {
- static constexpr size_t Value = 0;
+ static constexpr size_t Value = 0;
};
}
@@ -317,10 +317,10 @@ public:
private:
static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value");
- static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
- static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
- static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1;
- static constexpr TChunk FullChunk = (TChunk)~TChunk(0);
+ static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
+ static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
+ static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1;
+ static constexpr TChunk FullChunk = (TChunk)~TChunk(0);
template <class>
friend class TBitMapOps;
@@ -328,7 +328,7 @@ private:
using TStorage = typename TTraits::TStorage;
// The smallest unsigned type, which can be used in bit ops
- using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>;
+ using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>;
TStorage Mask;
@@ -383,13 +383,13 @@ public:
private:
struct TSetOp {
- static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
+ static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
return src | mask;
}
};
struct TResetOp {
- static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
+ static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
return src & ~mask;
}
};
@@ -510,7 +510,7 @@ public:
Y_FORCE_INLINE TReference operator[](size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
return TReference(&Mask.Data[pos >> DivCount], ModMask & pos);
}
@@ -520,14 +520,14 @@ public:
Y_FORCE_INLINE TThis& Set(size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
Mask.Data[pos >> DivCount] |= static_cast<TChunk>(1) << (pos & ModMask);
return *this;
}
// Fills the specified [start, end) bit range by the 1. Other bits are kept unchanged
TThis& Set(size_t start, size_t end) {
- Y_ASSERT(start <= end);
+ Y_ASSERT(start <= end);
if (start < end) {
Reserve(end);
UpdateRange<TSetOp>(start, end);
@@ -544,7 +544,7 @@ public:
// Clears the specified [start, end) bit range. Other bits are kept unchanged
TThis& Reset(size_t start, size_t end) {
- Y_ASSERT(start <= end);
+ Y_ASSERT(start <= end);
if (start < end && (start >> DivCount) < Mask.GetChunkCapacity()) {
UpdateRange<TResetOp>(start, Min(end, Mask.GetBitCapacity()));
}
@@ -553,7 +553,7 @@ public:
Y_FORCE_INLINE TThis& Flip(size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
Mask.Data[pos >> DivCount] ^= static_cast<TChunk>(1) << (pos & ModMask);
return *this;
}
@@ -580,7 +580,7 @@ public:
} else if ((pos & (sizeof(TTo) * 8 - 1)) == 0 && sizeof(TChunk) >= 2 * sizeof(TTo))
to = (TTo)(Mask.Data[chunkpos] >> (pos & ModMask));
else {
- static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3;
+ static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3;
TTo temp[copyToSize] = {0, 0};
//or use non defined by now TBitmap<copyToSize, TTo>::CopyData,RShift(pos & ModMask),Export(0,to)
NBitMapPrivate::CopyData(temp, copyToSize, Mask.Data + chunkpos, Min((sizeof(TTo) / sizeof(TChunk)) + 1, Mask.GetChunkCapacity() - chunkpos));
@@ -611,12 +611,12 @@ public:
}
// Returns bits capacity
- Y_FORCE_INLINE constexpr size_t Size() const noexcept {
+ Y_FORCE_INLINE constexpr size_t Size() const noexcept {
return Mask.GetBitCapacity();
}
Y_FORCE_INLINE void Reserve(size_t bitCount) {
- Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity");
+ Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity");
}
Y_FORCE_INLINE size_t ValueBitCount() const {
@@ -624,7 +624,7 @@ public:
while (nonZeroChunk != 0 && !Mask.Data[nonZeroChunk])
--nonZeroChunk;
return nonZeroChunk || Mask.Data[nonZeroChunk]
- ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk]))
+ ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk]))
: 0;
}
@@ -926,7 +926,7 @@ public:
// for (size_t pos = bits.FirstNonZeroBit(); pos != bits.Size(); pos = bits.NextNonZeroBit(pos)) {
// ...
// }
- // See Y_FOR_EACH_BIT macro definition at the bottom
+ // See Y_FOR_EACH_BIT macro definition at the bottom
size_t NextNonZeroBit(size_t pos) const {
size_t i = (pos + 1) >> DivCount;
if (i < Mask.GetChunkCapacity()) {
@@ -958,16 +958,16 @@ public:
return count;
}
- void Save(IOutputStream* out) const {
+ void Save(IOutputStream* out) const {
::Save(out, ui8(sizeof(TChunk)));
::Save(out, ui64(Size()));
::SavePodArray(out, Mask.Data, Mask.GetChunkCapacity());
}
- void Load(IInputStream* inp) {
+ void Load(IInputStream* inp) {
ui8 chunkSize = 0;
::Load(inp, chunkSize);
- Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same");
+ Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same");
ui64 bitCount64 = 0;
::Load(inp, bitCount64);
@@ -1005,7 +1005,7 @@ public:
return Mask.Data;
}
- constexpr size_t GetChunkCount() const noexcept {
+ constexpr size_t GetChunkCount() const noexcept {
return Mask.GetChunkCapacity();
}
};
@@ -1104,7 +1104,7 @@ public:
using TDynBitMap = TBitMapOps<TDynamicBitMapTraits<ui64>>;
-#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var))
+#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var))
template <typename TTraits>
struct THash<TBitMapOps<TTraits>> {
diff --git a/util/generic/bitmap_ut.cpp b/util/generic/bitmap_ut.cpp
index 087d34a8dc..47032bfe53 100644
--- a/util/generic/bitmap_ut.cpp
+++ b/util/generic/bitmap_ut.cpp
@@ -37,8 +37,8 @@
} \
}
-Y_UNIT_TEST_SUITE(TBitMapTest) {
- Y_UNIT_TEST(TestBitMap) {
+Y_UNIT_TEST_SUITE(TBitMapTest) {
+ Y_UNIT_TEST(TestBitMap) {
TBitMap<101> bitmap;
UNIT_ASSERT_EQUAL(bitmap.Size(), 101);
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap.Empty(), true);
}
- Y_UNIT_TEST(TestDynBitMap) {
+ Y_UNIT_TEST(TestDynBitMap) {
TDynBitMap bitmap;
UNIT_ASSERT_EQUAL(bitmap.Size(), 64); // Initial capacity
@@ -124,11 +124,11 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
CHECK_BITMAP(bitmap2, initBits2);
}
- Y_UNIT_TEST(TestAndFixed) {
+ Y_UNIT_TEST(TestAndFixed) {
TestAndImpl<TBitMap<101>>();
}
- Y_UNIT_TEST(TestAndDyn) {
+ Y_UNIT_TEST(TestAndDyn) {
TestAndImpl<TDynBitMap>();
}
@@ -165,15 +165,15 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap2 | (bitmap1 << 66), TBitMapImpl(bitmap2).Or(bitmap1, 66));
}
- Y_UNIT_TEST(TestOrFixed) {
+ Y_UNIT_TEST(TestOrFixed) {
TestOrImpl<TBitMap<145>>();
}
- Y_UNIT_TEST(TestOrDyn) {
+ Y_UNIT_TEST(TestOrDyn) {
TestOrImpl<TDynBitMap>();
}
- Y_UNIT_TEST(TestCopy) {
+ Y_UNIT_TEST(TestCopy) {
TBitMap<101> bitmap1;
size_t initBits[] = {0, 10, 11, 76, 100};
@@ -239,7 +239,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
CHECK_BITMAP(bitmap16, initBits);
}
- Y_UNIT_TEST(TestOps) {
+ Y_UNIT_TEST(TestOps) {
TBitMap<16> bitmap1;
TBitMap<12> bitmap2;
size_t initBits1[] = {0, 3, 7, 11};
@@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(tst3, (1 << 14));
}
- Y_UNIT_TEST(TestShiftFixed) {
+ Y_UNIT_TEST(TestShiftFixed) {
size_t initBits[] = {0, 3, 7, 11};
TBitMap<128> bitmap1;
@@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap1.Empty(), true);
}
- Y_UNIT_TEST(TestShiftDyn) {
+ Y_UNIT_TEST(TestShiftDyn) {
size_t initBits[] = {0, 3, 7, 11};
TDynBitMap bitmap1;
@@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
}
// Test that we don't expand bitmap in LShift when high-order bits are zero
- Y_UNIT_TEST(TestShiftExpansion) {
+ Y_UNIT_TEST(TestShiftExpansion) {
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(1).Size(), 64);
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(65).Size(), 64);
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(128).Size(), 64);
@@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap.Size(), 256);
}
- Y_UNIT_TEST(TestFixedSanity) {
+ Y_UNIT_TEST(TestFixedSanity) {
// test extra-bit cleanup
UNIT_ASSERT_EQUAL(TBitMap<33>().Set(0).LShift(34).RShift(34).Empty(), true);
UNIT_ASSERT_EQUAL(TBitMap<88>().Set(0).Set(1).Set(2).LShift(90).RShift(90).Empty(), true);
@@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(TBitMap<33>().Xor(TBitMap<40>().Set(39)).Empty(), true);
}
- Y_UNIT_TEST(TestIterate) {
+ Y_UNIT_TEST(TestIterate) {
TDynBitMap bitmap1;
TDynBitMap bitmap2;
@@ -475,7 +475,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap4.NextNonZeroBit(533), bitmap4.Size());
}
- Y_UNIT_TEST(TestHashFixed) {
+ Y_UNIT_TEST(TestHashFixed) {
TBitMap<32, ui8> bitmap32;
TBitMap<32, ui8> bitmap322;
TBitMap<64, ui8> bitmap64;
@@ -507,7 +507,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
}
- Y_UNIT_TEST(TestHashDynamic) {
+ Y_UNIT_TEST(TestHashDynamic) {
TDynBitMap bitmap1;
TDynBitMap bitmap2;
@@ -528,7 +528,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
}
- Y_UNIT_TEST(TestHashMixed) {
+ Y_UNIT_TEST(TestHashMixed) {
static_assert((std::is_same<TDynBitMap::TChunk, ui64>::value), "expect (TSameType<TDynBitMap::TChunk, ui64>::Result)");
TBitMap<sizeof(ui64) * 16, ui64> bitmapFixed;
@@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
}
- Y_UNIT_TEST(TestSetResetRange) {
+ Y_UNIT_TEST(TestSetResetRange) {
// Single chunk
using TBitMap1Chunk = TBitMap<64>;
UNIT_ASSERT_EQUAL(TBitMap1Chunk().Flip().Reset(10, 50), TBitMap1Chunk().Set(0, 10).Set(50, 64));
@@ -572,7 +572,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(TBitMap4Chunks().Flip().Reset(0, 10).Reset(50, 64), TBitMap4Chunks().Set(10, 50));
}
- Y_UNIT_TEST(TestSetRangeDyn) {
+ Y_UNIT_TEST(TestSetRangeDyn) {
for (size_t start = 0; start < 192; ++start) {
for (size_t end = start; end < 192; ++end) {
TDynBitMap bm;
diff --git a/util/generic/bitops.cpp b/util/generic/bitops.cpp
index db5667a21f..cee2667f4b 100644
--- a/util/generic/bitops.cpp
+++ b/util/generic/bitops.cpp
@@ -1,141 +1,141 @@
#include "bitops.h"
-
-namespace NBitOps {
- namespace NPrivate {
- const ui64 WORD_MASK[] = {
- 0x0000000000000000ULL,
- 0x0000000000000001ULL,
- 0x0000000000000003ULL,
- 0x0000000000000007ULL,
- 0x000000000000000FULL,
- 0x000000000000001FULL,
- 0x000000000000003FULL,
- 0x000000000000007FULL,
- 0x00000000000000FFULL,
- 0x00000000000001FFULL,
- 0x00000000000003FFULL,
- 0x00000000000007FFULL,
- 0x0000000000000FFFULL,
- 0x0000000000001FFFULL,
- 0x0000000000003FFFULL,
- 0x0000000000007FFFULL,
- 0x000000000000FFFFULL,
- 0x000000000001FFFFULL,
- 0x000000000003FFFFULL,
- 0x000000000007FFFFULL,
- 0x00000000000FFFFFULL,
- 0x00000000001FFFFFULL,
- 0x00000000003FFFFFULL,
- 0x00000000007FFFFFULL,
- 0x0000000000FFFFFFULL,
- 0x0000000001FFFFFFULL,
- 0x0000000003FFFFFFULL,
- 0x0000000007FFFFFFULL,
- 0x000000000FFFFFFFULL,
- 0x000000001FFFFFFFULL,
- 0x000000003FFFFFFFULL,
- 0x000000007FFFFFFFULL,
- 0x00000000FFFFFFFFULL,
- 0x00000001FFFFFFFFULL,
- 0x00000003FFFFFFFFULL,
- 0x00000007FFFFFFFFULL,
- 0x0000000FFFFFFFFFULL,
- 0x0000001FFFFFFFFFULL,
- 0x0000003FFFFFFFFFULL,
- 0x0000007FFFFFFFFFULL,
- 0x000000FFFFFFFFFFULL,
- 0x000001FFFFFFFFFFULL,
- 0x000003FFFFFFFFFFULL,
- 0x000007FFFFFFFFFFULL,
- 0x00000FFFFFFFFFFFULL,
- 0x00001FFFFFFFFFFFULL,
- 0x00003FFFFFFFFFFFULL,
- 0x00007FFFFFFFFFFFULL,
- 0x0000FFFFFFFFFFFFULL,
- 0x0001FFFFFFFFFFFFULL,
- 0x0003FFFFFFFFFFFFULL,
- 0x0007FFFFFFFFFFFFULL,
- 0x000FFFFFFFFFFFFFULL,
- 0x001FFFFFFFFFFFFFULL,
- 0x003FFFFFFFFFFFFFULL,
- 0x007FFFFFFFFFFFFFULL,
- 0x00FFFFFFFFFFFFFFULL,
- 0x01FFFFFFFFFFFFFFULL,
- 0x03FFFFFFFFFFFFFFULL,
- 0x07FFFFFFFFFFFFFFULL,
- 0x0FFFFFFFFFFFFFFFULL,
- 0x1FFFFFFFFFFFFFFFULL,
- 0x3FFFFFFFFFFFFFFFULL,
- 0x7FFFFFFFFFFFFFFFULL,
- 0xFFFFFFFFFFFFFFFFULL,
- };
-
- const ui64 INVERSE_WORD_MASK[] = {
- ~0x0000000000000000ULL,
- ~0x0000000000000001ULL,
- ~0x0000000000000003ULL,
- ~0x0000000000000007ULL,
- ~0x000000000000000FULL,
- ~0x000000000000001FULL,
- ~0x000000000000003FULL,
- ~0x000000000000007FULL,
- ~0x00000000000000FFULL,
- ~0x00000000000001FFULL,
- ~0x00000000000003FFULL,
- ~0x00000000000007FFULL,
- ~0x0000000000000FFFULL,
- ~0x0000000000001FFFULL,
- ~0x0000000000003FFFULL,
- ~0x0000000000007FFFULL,
- ~0x000000000000FFFFULL,
- ~0x000000000001FFFFULL,
- ~0x000000000003FFFFULL,
- ~0x000000000007FFFFULL,
- ~0x00000000000FFFFFULL,
- ~0x00000000001FFFFFULL,
- ~0x00000000003FFFFFULL,
- ~0x00000000007FFFFFULL,
- ~0x0000000000FFFFFFULL,
- ~0x0000000001FFFFFFULL,
- ~0x0000000003FFFFFFULL,
- ~0x0000000007FFFFFFULL,
- ~0x000000000FFFFFFFULL,
- ~0x000000001FFFFFFFULL,
- ~0x000000003FFFFFFFULL,
- ~0x000000007FFFFFFFULL,
- ~0x00000000FFFFFFFFULL,
- ~0x00000001FFFFFFFFULL,
- ~0x00000003FFFFFFFFULL,
- ~0x00000007FFFFFFFFULL,
- ~0x0000000FFFFFFFFFULL,
- ~0x0000001FFFFFFFFFULL,
- ~0x0000003FFFFFFFFFULL,
- ~0x0000007FFFFFFFFFULL,
- ~0x000000FFFFFFFFFFULL,
- ~0x000001FFFFFFFFFFULL,
- ~0x000003FFFFFFFFFFULL,
- ~0x000007FFFFFFFFFFULL,
- ~0x00000FFFFFFFFFFFULL,
- ~0x00001FFFFFFFFFFFULL,
- ~0x00003FFFFFFFFFFFULL,
- ~0x00007FFFFFFFFFFFULL,
- ~0x0000FFFFFFFFFFFFULL,
- ~0x0001FFFFFFFFFFFFULL,
- ~0x0003FFFFFFFFFFFFULL,
- ~0x0007FFFFFFFFFFFFULL,
- ~0x000FFFFFFFFFFFFFULL,
- ~0x001FFFFFFFFFFFFFULL,
- ~0x003FFFFFFFFFFFFFULL,
- ~0x007FFFFFFFFFFFFFULL,
- ~0x00FFFFFFFFFFFFFFULL,
- ~0x01FFFFFFFFFFFFFFULL,
- ~0x03FFFFFFFFFFFFFFULL,
- ~0x07FFFFFFFFFFFFFFULL,
- ~0x0FFFFFFFFFFFFFFFULL,
- ~0x1FFFFFFFFFFFFFFFULL,
- ~0x3FFFFFFFFFFFFFFFULL,
- ~0x7FFFFFFFFFFFFFFFULL,
- ~0xFFFFFFFFFFFFFFFFULL,
- };
+
+namespace NBitOps {
+ namespace NPrivate {
+ const ui64 WORD_MASK[] = {
+ 0x0000000000000000ULL,
+ 0x0000000000000001ULL,
+ 0x0000000000000003ULL,
+ 0x0000000000000007ULL,
+ 0x000000000000000FULL,
+ 0x000000000000001FULL,
+ 0x000000000000003FULL,
+ 0x000000000000007FULL,
+ 0x00000000000000FFULL,
+ 0x00000000000001FFULL,
+ 0x00000000000003FFULL,
+ 0x00000000000007FFULL,
+ 0x0000000000000FFFULL,
+ 0x0000000000001FFFULL,
+ 0x0000000000003FFFULL,
+ 0x0000000000007FFFULL,
+ 0x000000000000FFFFULL,
+ 0x000000000001FFFFULL,
+ 0x000000000003FFFFULL,
+ 0x000000000007FFFFULL,
+ 0x00000000000FFFFFULL,
+ 0x00000000001FFFFFULL,
+ 0x00000000003FFFFFULL,
+ 0x00000000007FFFFFULL,
+ 0x0000000000FFFFFFULL,
+ 0x0000000001FFFFFFULL,
+ 0x0000000003FFFFFFULL,
+ 0x0000000007FFFFFFULL,
+ 0x000000000FFFFFFFULL,
+ 0x000000001FFFFFFFULL,
+ 0x000000003FFFFFFFULL,
+ 0x000000007FFFFFFFULL,
+ 0x00000000FFFFFFFFULL,
+ 0x00000001FFFFFFFFULL,
+ 0x00000003FFFFFFFFULL,
+ 0x00000007FFFFFFFFULL,
+ 0x0000000FFFFFFFFFULL,
+ 0x0000001FFFFFFFFFULL,
+ 0x0000003FFFFFFFFFULL,
+ 0x0000007FFFFFFFFFULL,
+ 0x000000FFFFFFFFFFULL,
+ 0x000001FFFFFFFFFFULL,
+ 0x000003FFFFFFFFFFULL,
+ 0x000007FFFFFFFFFFULL,
+ 0x00000FFFFFFFFFFFULL,
+ 0x00001FFFFFFFFFFFULL,
+ 0x00003FFFFFFFFFFFULL,
+ 0x00007FFFFFFFFFFFULL,
+ 0x0000FFFFFFFFFFFFULL,
+ 0x0001FFFFFFFFFFFFULL,
+ 0x0003FFFFFFFFFFFFULL,
+ 0x0007FFFFFFFFFFFFULL,
+ 0x000FFFFFFFFFFFFFULL,
+ 0x001FFFFFFFFFFFFFULL,
+ 0x003FFFFFFFFFFFFFULL,
+ 0x007FFFFFFFFFFFFFULL,
+ 0x00FFFFFFFFFFFFFFULL,
+ 0x01FFFFFFFFFFFFFFULL,
+ 0x03FFFFFFFFFFFFFFULL,
+ 0x07FFFFFFFFFFFFFFULL,
+ 0x0FFFFFFFFFFFFFFFULL,
+ 0x1FFFFFFFFFFFFFFFULL,
+ 0x3FFFFFFFFFFFFFFFULL,
+ 0x7FFFFFFFFFFFFFFFULL,
+ 0xFFFFFFFFFFFFFFFFULL,
+ };
+
+ const ui64 INVERSE_WORD_MASK[] = {
+ ~0x0000000000000000ULL,
+ ~0x0000000000000001ULL,
+ ~0x0000000000000003ULL,
+ ~0x0000000000000007ULL,
+ ~0x000000000000000FULL,
+ ~0x000000000000001FULL,
+ ~0x000000000000003FULL,
+ ~0x000000000000007FULL,
+ ~0x00000000000000FFULL,
+ ~0x00000000000001FFULL,
+ ~0x00000000000003FFULL,
+ ~0x00000000000007FFULL,
+ ~0x0000000000000FFFULL,
+ ~0x0000000000001FFFULL,
+ ~0x0000000000003FFFULL,
+ ~0x0000000000007FFFULL,
+ ~0x000000000000FFFFULL,
+ ~0x000000000001FFFFULL,
+ ~0x000000000003FFFFULL,
+ ~0x000000000007FFFFULL,
+ ~0x00000000000FFFFFULL,
+ ~0x00000000001FFFFFULL,
+ ~0x00000000003FFFFFULL,
+ ~0x00000000007FFFFFULL,
+ ~0x0000000000FFFFFFULL,
+ ~0x0000000001FFFFFFULL,
+ ~0x0000000003FFFFFFULL,
+ ~0x0000000007FFFFFFULL,
+ ~0x000000000FFFFFFFULL,
+ ~0x000000001FFFFFFFULL,
+ ~0x000000003FFFFFFFULL,
+ ~0x000000007FFFFFFFULL,
+ ~0x00000000FFFFFFFFULL,
+ ~0x00000001FFFFFFFFULL,
+ ~0x00000003FFFFFFFFULL,
+ ~0x00000007FFFFFFFFULL,
+ ~0x0000000FFFFFFFFFULL,
+ ~0x0000001FFFFFFFFFULL,
+ ~0x0000003FFFFFFFFFULL,
+ ~0x0000007FFFFFFFFFULL,
+ ~0x000000FFFFFFFFFFULL,
+ ~0x000001FFFFFFFFFFULL,
+ ~0x000003FFFFFFFFFFULL,
+ ~0x000007FFFFFFFFFFULL,
+ ~0x00000FFFFFFFFFFFULL,
+ ~0x00001FFFFFFFFFFFULL,
+ ~0x00003FFFFFFFFFFFULL,
+ ~0x00007FFFFFFFFFFFULL,
+ ~0x0000FFFFFFFFFFFFULL,
+ ~0x0001FFFFFFFFFFFFULL,
+ ~0x0003FFFFFFFFFFFFULL,
+ ~0x0007FFFFFFFFFFFFULL,
+ ~0x000FFFFFFFFFFFFFULL,
+ ~0x001FFFFFFFFFFFFFULL,
+ ~0x003FFFFFFFFFFFFFULL,
+ ~0x007FFFFFFFFFFFFFULL,
+ ~0x00FFFFFFFFFFFFFFULL,
+ ~0x01FFFFFFFFFFFFFFULL,
+ ~0x03FFFFFFFFFFFFFFULL,
+ ~0x07FFFFFFFFFFFFFFULL,
+ ~0x0FFFFFFFFFFFFFFFULL,
+ ~0x1FFFFFFFFFFFFFFFULL,
+ ~0x3FFFFFFFFFFFFFFFULL,
+ ~0x7FFFFFFFFFFFFFFFULL,
+ ~0xFFFFFFFFFFFFFFFFULL,
+ };
}
}
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index 2db15fc59b..2c60e3437f 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -3,16 +3,16 @@
#include "ylimits.h"
#include "typelist.h"
-#include <util/system/compiler.h>
+#include <util/system/compiler.h>
#include <util/system/yassert.h>
-#ifdef _MSC_VER
+#ifdef _MSC_VER
#include <intrin.h>
-#endif
-
+#endif
+
namespace NBitOps {
namespace NPrivate {
- template <unsigned N, typename T>
+ template <unsigned N, typename T>
struct TClp2Helper {
static Y_FORCE_INLINE T Calc(T t) noexcept {
const T prev = TClp2Helper<N / 2, T>::Calc(t);
@@ -21,272 +21,272 @@ namespace NBitOps {
}
};
- template <typename T>
+ template <typename T>
struct TClp2Helper<0u, T> {
static Y_FORCE_INLINE T Calc(T t) noexcept {
return t - 1;
}
};
- extern const ui64 WORD_MASK[];
- extern const ui64 INVERSE_WORD_MASK[];
-
- // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
-
+ extern const ui64 WORD_MASK[];
+ extern const ui64 INVERSE_WORD_MASK[];
+
+ // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
+
Y_FORCE_INLINE ui64 SwapOddEvenBits(ui64 v) {
- return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL);
- }
-
+ return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapBitPairs(ui64 v) {
- return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL);
- }
-
+ return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapNibbles(ui64 v) {
- return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL);
- }
-
+ return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapOddEvenBytes(ui64 v) {
- return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL);
- }
-
+ return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapBytePairs(ui64 v) {
- return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL);
- }
-
+ return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapByteQuads(ui64 v) {
- return (v >> 32ULL) | (v << 32ULL);
- }
-
+ return (v >> 32ULL) | (v << 32ULL);
+ }
+
#if defined(__GNUC__)
inline unsigned GetValueBitCountImpl(unsigned int value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
- }
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
+ }
inline unsigned GetValueBitCountImpl(unsigned long value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value);
- }
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value);
+ }
inline unsigned GetValueBitCountImpl(unsigned long long value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value);
- }
-#else
- /// Stupid realization for non-GCC. Can use BSR from x86 instructions set.
- template <typename T>
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value);
+ }
+#else
+ /// Stupid realization for non-GCC. Can use BSR from x86 instructions set.
+ template <typename T>
inline unsigned GetValueBitCountImpl(T value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT().
- value >>= 1;
- while (value) {
- value >>= 1;
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT().
+ value >>= 1;
+ while (value) {
+ value >>= 1;
++result;
- }
+ }
- return result;
- }
-#endif
+ return result;
+ }
+#endif
#if defined(__GNUC__)
inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctz(value);
- }
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctz(value);
+ }
inline unsigned CountTrailingZeroBitsImpl(unsigned long value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctzl(value);
- }
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctzl(value);
+ }
inline unsigned CountTrailingZeroBitsImpl(unsigned long long value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctzll(value);
- }
-#else
- /// Stupid realization for non-GCC. Can use BSF from x86 instructions set.
- template <typename T>
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctzll(value);
+ }
+#else
+ /// Stupid realization for non-GCC. Can use BSF from x86 instructions set.
+ template <typename T>
inline unsigned CountTrailingZeroBitsImpl(T value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- unsigned result = 0;
- while (!(value & 1)) {
- value >>= 1;
- ++result;
- }
-
- return result;
- }
-#endif
-
- template <typename T>
- Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept {
- constexpr ui8 bits = sizeof(T) * 8;
- constexpr ui8 mask = bits - 1;
- Y_ASSERT(shift <= mask);
-
- // do trick with mask to avoid undefined behaviour
- return (value << shift) | (value >> ((-shift) & mask));
- }
-
- template <typename T>
- Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept {
- constexpr ui8 bits = sizeof(T) * 8;
- constexpr ui8 mask = bits - 1;
- Y_ASSERT(shift <= mask);
-
- // do trick with mask to avoid undefined behaviour
- return (value >> shift) | (value << ((-shift) & mask));
- }
-
-#if defined(_x86_) && defined(__GNUC__)
- Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept {
- __asm__("rorb %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept {
- __asm__("rorw %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept {
- __asm__("rorl %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept {
- __asm__("rolb %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept {
- __asm__("rolw %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept {
- __asm__("roll %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ unsigned result = 0;
+ while (!(value & 1)) {
+ value >>= 1;
+ ++result;
+ }
+
+ return result;
+ }
+#endif
+
+ template <typename T>
+ Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept {
+ constexpr ui8 bits = sizeof(T) * 8;
+ constexpr ui8 mask = bits - 1;
+ Y_ASSERT(shift <= mask);
+
+ // do trick with mask to avoid undefined behaviour
+ return (value << shift) | (value >> ((-shift) & mask));
+ }
+
+ template <typename T>
+ Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept {
+ constexpr ui8 bits = sizeof(T) * 8;
+ constexpr ui8 mask = bits - 1;
+ Y_ASSERT(shift <= mask);
+
+ // do trick with mask to avoid undefined behaviour
+ return (value >> shift) | (value << ((-shift) & mask));
+ }
+
+#if defined(_x86_) && defined(__GNUC__)
+ Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept {
+ __asm__("rorb %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept {
+ __asm__("rorw %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept {
+ __asm__("rorl %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept {
+ __asm__("rolb %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept {
+ __asm__("rolw %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept {
+ __asm__("roll %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
#if defined(_x86_64_)
- Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept {
- __asm__("rorq %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept {
- __asm__("rolq %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
+ Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept {
+ __asm__("rorq %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept {
+ __asm__("rolq %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
#endif
-#endif
+#endif
}
}
-
-/**
+
+/**
* Computes the next power of 2 higher or equal to the integer parameter `t`.
- * If `t` is a power of 2 will return `t`.
- * Result is undefined for `t == 0`.
- */
+ * If `t` is a power of 2 will return `t`.
+ * Result is undefined for `t == 0`.
+ */
template <typename T>
static inline T FastClp2(T t) noexcept {
- Y_ASSERT(t > 0);
+ Y_ASSERT(t > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t));
+ return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t));
}
-/**
- * Check if integer is a power of 2.
- */
-template <typename T>
+/**
+ * Check if integer is a power of 2.
+ */
+template <typename T>
Y_CONST_FUNCTION constexpr bool IsPowerOf2(T v) noexcept {
- return v > 0 && (v & (v - 1)) == 0;
-}
+ return v > 0 && (v & (v - 1)) == 0;
+}
-/**
- * Returns the number of leading 0-bits in `value`, starting at the most significant bit position.
- */
+/**
+ * Returns the number of leading 0-bits in `value`, starting at the most significant bit position.
+ */
template <typename T>
static inline unsigned GetValueBitCount(T value) noexcept {
- Y_ASSERT(value > 0);
+ Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
+ return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
}
-/**
- * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position
- */
-template <typename T>
+/**
+ * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position
+ */
+template <typename T>
static inline unsigned CountTrailingZeroBits(T value) noexcept {
- Y_ASSERT(value > 0);
+ Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
+ return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
}
-
-/*
- * Returns 64-bit mask with `bits` lower bits set.
- */
+
+/*
+ * Returns 64-bit mask with `bits` lower bits set.
+ */
Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits) {
- return ::NBitOps::NPrivate::WORD_MASK[bits];
-}
-
-/*
- * Return 64-bit mask with `bits` set starting from `skipbits`.
- */
+ return ::NBitOps::NPrivate::WORD_MASK[bits];
+}
+
+/*
+ * Return 64-bit mask with `bits` set starting from `skipbits`.
+ */
Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits, ui64 skipbits) {
- return MaskLowerBits(bits) << skipbits;
-}
-
-/*
- * Return 64-bit mask with all bits set except for `bits` lower bits.
- */
+ return MaskLowerBits(bits) << skipbits;
+}
+
+/*
+ * Return 64-bit mask with all bits set except for `bits` lower bits.
+ */
Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits) {
- return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits];
-}
-
-/*
- * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`.
- */
+ return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits];
+}
+
+/*
+ * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`.
+ */
Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) {
- return ~MaskLowerBits(bits, skipbits);
-}
-
-/*
+ return ~MaskLowerBits(bits, skipbits);
+}
+
+/*
* Returns 0-based position of the most significant bit that is set. 0 for 0.
- */
+ */
Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) {
-#ifdef __GNUC__
- ui64 res = v ? (63 - __builtin_clzll(v)) : 0;
-#elif defined(_MSC_VER) && defined(_64_)
- unsigned long res = 0;
- if (v)
- _BitScanReverse64(&res, v);
-#else
- ui64 res = 0;
- if (v)
- while (v >>= 1)
+#ifdef __GNUC__
+ ui64 res = v ? (63 - __builtin_clzll(v)) : 0;
+#elif defined(_MSC_VER) && defined(_64_)
+ unsigned long res = 0;
+ if (v)
+ _BitScanReverse64(&res, v);
+#else
+ ui64 res = 0;
+ if (v)
+ while (v >>= 1)
++res;
-#endif
- return res;
-}
-
+#endif
+ return res;
+}
+
/**
* Returns 0-based position of the least significant bit that is set. 0 for 0.
*/
@@ -309,7 +309,7 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) {
return res;
}
-/*
+/*
* Returns 0 - based position of the most significant bit (compile time)
* 0 for 0.
*/
@@ -318,112 +318,112 @@ constexpr ui64 MostSignificantBitCT(ui64 x) {
}
/*
- * Return rounded up binary logarithm of `x`.
- */
+ * Return rounded up binary logarithm of `x`.
+ */
Y_FORCE_INLINE ui8 CeilLog2(ui64 x) {
- return static_cast<ui8>(MostSignificantBit(x - 1)) + 1;
-}
-
+ return static_cast<ui8>(MostSignificantBit(x - 1)) + 1;
+}
+
Y_FORCE_INLINE ui8 ReverseBytes(ui8 t) {
- return t;
-}
-
+ return t;
+}
+
Y_FORCE_INLINE ui16 ReverseBytes(ui16 t) {
- return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t));
-}
-
+ return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t));
+}
+
Y_FORCE_INLINE ui32 ReverseBytes(ui32 t) {
- return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(t)));
-}
-
+ return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(t)));
+}
+
Y_FORCE_INLINE ui64 ReverseBytes(ui64 t) {
- return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t)));
-}
-
+ return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t)));
+}
+
Y_FORCE_INLINE ui8 ReverseBits(ui8 t) {
- return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))));
-}
-
+ return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))));
+}
+
Y_FORCE_INLINE ui16 ReverseBits(ui16 t) {
- return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t)))));
-}
-
+ return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t)))));
+}
+
Y_FORCE_INLINE ui32 ReverseBits(ui32 t) {
- return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
-}
-
+ return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
+}
+
Y_FORCE_INLINE ui64 ReverseBits(ui64 t) {
- return ::NBitOps::NPrivate::SwapByteQuads(
- ::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
-}
-
-/*
- * Reverse first `bits` bits
- * 1000111000111000 , bits = 6 => 1000111000000111
- */
-template <typename T>
+ return ::NBitOps::NPrivate::SwapByteQuads(
+ ::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
+}
+
+/*
+ * Reverse first `bits` bits
+ * 1000111000111000 , bits = 6 => 1000111000000111
+ */
+template <typename T>
Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) {
return bits ? (T(v & ::InverseMaskLowerBits(bits)) | T(ReverseBits(T(v & ::MaskLowerBits(bits)))) >> ((ui64{sizeof(T)} << ui64{3}) - bits)) : v;
-}
-
-/*
- * Referse first `bits` bits starting from `skipbits` bits
- * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100
- */
-template <typename T>
+}
+
+/*
+ * Referse first `bits` bits starting from `skipbits` bits
+ * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100
+ */
+template <typename T>
Y_FORCE_INLINE T ReverseBits(T v, ui64 bits, ui64 skipbits) {
- return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits));
-}
-
-/* Rotate bits left. Also known as left circular shift.
- */
-template <typename T>
-Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
- return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift);
-}
-
-/* Rotate bits right. Also known as right circular shift.
- */
-template <typename T>
-Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
- return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift);
-}
-
-/* Rotate bits left. Also known as left circular shift.
- */
-template <typename T>
-constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
-
- // do trick with mask to avoid undefined behaviour
- return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1)));
-}
-
-/* Rotate bits right. Also known as right circular shift.
- */
-template <typename T>
-constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
-
- // do trick with mask to avoid undefined behaviour
- return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1)));
-}
+ return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits));
+}
+
+/* Rotate bits left. Also known as left circular shift.
+ */
+template <typename T>
+Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+ return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift);
+}
+
+/* Rotate bits right. Also known as right circular shift.
+ */
+template <typename T>
+Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+ return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift);
+}
+
+/* Rotate bits left. Also known as left circular shift.
+ */
+template <typename T>
+constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+
+ // do trick with mask to avoid undefined behaviour
+ return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1)));
+}
+
+/* Rotate bits right. Also known as right circular shift.
+ */
+template <typename T>
+constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+
+ // do trick with mask to avoid undefined behaviour
+ return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1)));
+}
/* Remain `size` bits to current `offset` of `value`
size, offset are less than number of bits in size_type
diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp
index d23c2b5c27..4a1a6b799e 100644
--- a/util/generic/bitops_ut.cpp
+++ b/util/generic/bitops_ut.cpp
@@ -4,45 +4,45 @@
#include <util/string/builder.h>
-template <typename T>
-static void TestCTZ() {
- for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) {
- UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i);
- }
-}
-
-template <typename T>
-static void TestFastClp2ForEachPowerOf2() {
- for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) {
- const auto current = T(1) << i;
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current);
- }
-
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1));
- for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) {
- for (size_t j = 0; j < i; ++j) {
- const auto value = (T(1) << i) | (T(1) << j);
- const auto next = T(1) << (i + 1);
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next);
- }
- }
-}
-
-template <typename T>
-static T ReverseBitsSlow(T v) {
- T r = v; // r will be reversed bits of v; first get LSB of v
- ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end
-
- for (v >>= 1; v; v >>= 1) {
- r <<= 1;
- r |= v & 1;
+template <typename T>
+static void TestCTZ() {
+ for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) {
+ UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i);
+ }
+}
+
+template <typename T>
+static void TestFastClp2ForEachPowerOf2() {
+ for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) {
+ const auto current = T(1) << i;
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current);
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1));
+ for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) {
+ for (size_t j = 0; j < i; ++j) {
+ const auto value = (T(1) << i) | (T(1) << j);
+ const auto next = T(1) << (i + 1);
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next);
+ }
+ }
+}
+
+template <typename T>
+static T ReverseBitsSlow(T v) {
+ T r = v; // r will be reversed bits of v; first get LSB of v
+ ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end
+
+ for (v >>= 1; v; v >>= 1) {
+ r <<= 1;
+ r |= v & 1;
--s;
- }
-
- r <<= s; // shift when v's highest bits are zero
- return r;
-}
-
+ }
+
+ r <<= s; // shift when v's highest bits are zero
+ return r;
+}
+
// DO_NOT_STYLE
Y_UNIT_TEST_SUITE(TBitOpsTest) {
Y_UNIT_TEST(TestCountTrailingZeroBits) {
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
TestFastClp2ForEachPowerOf2<unsigned long>();
TestFastClp2ForEachPowerOf2<unsigned long long>();
}
-
+
Y_UNIT_TEST(TestMask) {
for (ui32 i = 0; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i), (ui64{1} << i) - 1);
@@ -79,8 +79,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i, i / 2), (ui64{1} << i) - 1 << (i / 2));
UNIT_ASSERT_VALUES_EQUAL(InverseMaskLowerBits(i, i / 2), ~MaskLowerBits(i, i / 2));
}
- }
-
+ }
+
Y_UNIT_TEST(TestMostSignificantBit) {
static_assert(MostSignificantBitCT(0) == 0, ".");
static_assert(MostSignificantBitCT(1) == 0, ".");
@@ -93,8 +93,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
for (ui32 i = 0; i < 63; ++i) {
UNIT_ASSERT_VALUES_EQUAL(i + 1, MostSignificantBit(ui64{3} << i));
}
- }
-
+ }
+
Y_UNIT_TEST(TestLeastSignificantBit) {
for (ui32 i = 0; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(i, LeastSignificantBit(ui64{1} << i));
@@ -112,13 +112,13 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
Y_UNIT_TEST(TestCeilLog2) {
UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1}), 1);
-
+
for (ui32 i = 2; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1} << i), i);
UNIT_ASSERT_VALUES_EQUAL(CeilLog2((ui64{1} << i) | ui64{1}), i + 1);
}
- }
-
+ }
+
Y_UNIT_TEST(TestReverse) {
for (ui64 i = 0; i < 0x100; ++i) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui8)i), ReverseBitsSlow((ui8)i));
@@ -129,23 +129,23 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui32)~i), ReverseBitsSlow((ui32)~i));
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui64)~i), ReverseBitsSlow((ui64)~i));
}
-
+
ui32 v = 0xF0F0F0F0; // 11110000111100001111000011110000
for (ui32 i = 0; i < 4; ++i) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, i + 1), v);
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 4 + 2 * i, 4 - i), v);
}
-
+
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8), 0xF0F0F00Fu);
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8, 4), 0xF0F0FF00u);
-
+
for (ui32 i = 0; i < 0x10000; ++i) {
for (ui32 j = 0; j <= 32; ++j) {
UNIT_ASSERT_VALUES_EQUAL_C(i, ReverseBits(ReverseBits(i, j), j), (TString)(TStringBuilder() << i << " " << j));
}
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(TestRotateBitsLeft) {
static_assert(RotateBitsLeftCT<ui8>(0b00000000u, 0) == 0b00000000u, "");
static_assert(RotateBitsLeftCT<ui8>(0b00000001u, 0) == 0b00000001u, "");
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui8>(0b00000101u, 1) == 0b00001010u, "");
static_assert(RotateBitsLeftCT<ui8>(0b10100000u, 1) == 0b01000001u, "");
static_assert(RotateBitsLeftCT<ui8>(0b10000000u, 7) == 0b01000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000000u, 0), 0b00000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000001u, 0), 0b00000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 0), 0b10000000u);
@@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000101u, 1), 0b00001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10100000u, 1), 0b01000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 7), 0b01000000u);
-
+
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, "");
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, "");
@@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000101u, 1) == 0b0000000000001010u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1010000000000000u, 1) == 0b0100000000000001u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 15) == 0b0100000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000000u, 0), 0b0000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000001u, 0), 0b0000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 0), 0b1000000000000000u);
@@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000101u, 1), 0b0000000000001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1010000000000000u, 1), 0b0100000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 15), 0b0100000000000000u);
-
+
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, "");
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, "");
@@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b00000000000000000000000000001010u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 31) == 0b01000000000000000000000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u);
@@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000101u, 1), 0b00000000000000000000000000001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10100000000000000000000000000000u, 1), 0b01000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 31), 0b01000000000000000000000000000000u);
-
+
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, "");
@@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b0000000000000000000000000000000000000000000000000000000000001010u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0100000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63) == 0b0100000000000000000000000000000000000000000000000000000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u);
@@ -219,7 +219,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1), 0b0100000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63), 0b0100000000000000000000000000000000000000000000000000000000000000u);
}
-
+
Y_UNIT_TEST(TestRotateBitsRight) {
static_assert(RotateBitsRightCT<ui8>(0b00000000u, 0) == 0b00000000u, "");
static_assert(RotateBitsRightCT<ui8>(0b00000001u, 0) == 0b00000001u, "");
@@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui8>(0b00000101u, 1) == 0b10000010u, "");
static_assert(RotateBitsRightCT<ui8>(0b10100000u, 1) == 0b01010000u, "");
static_assert(RotateBitsRightCT<ui8>(0b00000001u, 7) == 0b00000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000000u, 0), 0b00000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 0), 0b00000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10000000u, 0), 0b10000000u);
@@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000101u, 1), 0b10000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10100000u, 1), 0b01010000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 7), 0b00000010u);
-
+
static_assert(RotateBitsRightCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, "");
static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, "");
static_assert(RotateBitsRightCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, "");
@@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui16>(0b0000000000000101u, 1) == 0b1000000000000010u, "");
static_assert(RotateBitsRightCT<ui16>(0b1010000000000000u, 1) == 0b0101000000000000u, "");
static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 15) == 0b0000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000000u, 0), 0b0000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 0), 0b0000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1000000000000000u, 0), 0b1000000000000000u);
@@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000101u, 1), 0b1000000000000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1010000000000000u, 1), 0b0101000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 15), 0b0000000000000010u);
-
+
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, "");
static_assert(RotateBitsRightCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, "");
@@ -265,7 +265,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b10000000000000000000000000000010u, "");
static_assert(RotateBitsRightCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01010000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 31) == 0b00000000000000000000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u);
@@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000101u, 1), 0b10000000000000000000000000000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10100000000000000000000000000000u, 1), 0b01010000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 31), 0b00000000000000000000000000000010u);
-
+
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsRightCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, "");
@@ -283,7 +283,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b1000000000000000000000000000000000000000000000000000000000000010u, "");
static_assert(RotateBitsRightCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0101000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 63) == 0b0000000000000000000000000000000000000000000000000000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u);
diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp
index b92697e1d0..dd60963873 100644
--- a/util/generic/buffer.cpp
+++ b/util/generic/buffer.cpp
@@ -7,7 +7,7 @@
#include <util/system/sanitizers.h>
TBuffer::TBuffer(size_t len)
- : Data_(nullptr)
+ : Data_(nullptr)
, Len_(0)
, Pos_(0)
{
@@ -23,7 +23,7 @@ TBuffer::TBuffer(TBuffer&& b) noexcept
}
TBuffer::TBuffer(const char* buf, size_t len)
- : Data_(nullptr)
+ : Data_(nullptr)
, Len_(0)
, Pos_(0)
{
@@ -76,14 +76,14 @@ void TBuffer::DoReserve(size_t realLen) {
// FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>]
const size_t len = Max<size_t>(FastClp2(realLen), realLen);
- Y_ASSERT(realLen > Len_);
- Y_ASSERT(len >= realLen);
+ Y_ASSERT(realLen > Len_);
+ Y_ASSERT(len >= realLen);
Realloc(len);
}
void TBuffer::Realloc(size_t len) {
- Y_ASSERT(Pos_ <= len);
+ Y_ASSERT(Pos_ <= len);
Data_ = (char*)y_reallocate(Data_, len);
Len_ = len;
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index 9576467404..ee3e92e90d 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -42,7 +42,7 @@ public:
}
inline void EraseBack(size_t n) noexcept {
- Y_ASSERT(n <= Pos_);
+ Y_ASSERT(n <= Pos_);
Pos_ -= n;
}
@@ -131,7 +131,7 @@ public:
}
inline void Proceed(size_t pos) {
- //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021
+ //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021
Resize(pos);
}
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp
index 437d7122ec..3f1114018c 100644
--- a/util/generic/buffer_ut.cpp
+++ b/util/generic/buffer_ut.cpp
@@ -5,8 +5,8 @@
#include "vector.h"
#include "buffer.h"
-Y_UNIT_TEST_SUITE(TBufferTest) {
- Y_UNIT_TEST(TestEraseBack) {
+Y_UNIT_TEST_SUITE(TBufferTest) {
+ Y_UNIT_TEST(TestEraseBack) {
TBuffer buf;
buf.Append("1234567", 7);
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), "1234");
}
- Y_UNIT_TEST(TestAppend) {
+ Y_UNIT_TEST(TestAppend) {
const char data[] = "1234567890qwertyuiop";
TBuffer buf(13);
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str);
}
- Y_UNIT_TEST(TestReset) {
+ Y_UNIT_TEST(TestReset) {
char content[] = "some text";
TBuffer buf;
@@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(buf.Capacity(), 0);
}
- Y_UNIT_TEST(TestResize) {
+ Y_UNIT_TEST(TestResize) {
char content[] = "some text";
TBuffer buf;
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some");
}
- Y_UNIT_TEST(TestReserve) {
+ Y_UNIT_TEST(TestReserve) {
TBuffer buf;
UNIT_ASSERT_EQUAL(buf.Capacity(), 0);
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(buf.Capacity(), 2048);
}
- Y_UNIT_TEST(TestShrinkToFit) {
+ Y_UNIT_TEST(TestShrinkToFit) {
TBuffer buf;
TString content = "some text";
@@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
}
#if 0
-Y_UNIT_TEST(TestAlignUp) {
+Y_UNIT_TEST(TestAlignUp) {
char content[] = "some text";
TBuffer buf;
@@ -145,7 +145,7 @@ Y_UNIT_TEST(TestAlignUp) {
#endif
#if 0
-Y_UNIT_TEST(TestSpeed) {
+Y_UNIT_TEST(TestSpeed) {
const char data[] = "1234567890qwertyuiop";
const size_t c = 100000;
ui64 t1 = 0;
@@ -179,7 +179,7 @@ Y_UNIT_TEST(TestSpeed) {
}
#endif
- Y_UNIT_TEST(TestFillAndChop) {
+ Y_UNIT_TEST(TestFillAndChop) {
TBuffer buf;
buf.Append("Some ", 5);
buf.Fill('!', 5);
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 0d4a41f385..e1807ce1d8 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -13,12 +13,12 @@
template <class T, class F>
static inline T VerifyDynamicCast(F f) {
if (!f) {
- return nullptr;
+ return nullptr;
}
T ret = dynamic_cast<T>(f);
- Y_VERIFY(ret, "verify cast failed");
+ Y_VERIFY(ret, "verify cast failed");
return ret;
}
@@ -68,7 +68,7 @@ template <>
class TInteger<true> {
public:
template <class TUnsigned>
- static constexpr bool IsNegative(TUnsigned) noexcept {
+ static constexpr bool IsNegative(TUnsigned) noexcept {
return false;
}
};
@@ -77,13 +77,13 @@ template <>
class TInteger<false> {
public:
template <class TSigned>
- static constexpr bool IsNegative(const TSigned value) noexcept {
+ static constexpr bool IsNegative(const TSigned value) noexcept {
return value < 0;
}
};
template <class TType>
-constexpr bool IsNegative(const TType value) noexcept {
+constexpr bool IsNegative(const TType value) noexcept {
return TInteger<std::is_unsigned<TType>::value>::IsNegative(value);
}
@@ -93,7 +93,7 @@ namespace NPrivate {
std::is_enum<T>::value,
std::underlying_type<T>, // Lazy evaluatuion: do not call ::type here, because underlying_type<T> is undefined if T is not an enum.
std::enable_if<true, T> // Wrapping T in a class, that has member ::type typedef.
- >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if
+ >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if
template <class TSmall, class TLarge>
struct TSafelyConvertible {
@@ -112,15 +112,15 @@ constexpr std::enable_if_t<::NPrivate::TSafelyConvertible<TSmallInt, TLargeInt>:
}
template <class TSmall, class TLarge>
-inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) {
+inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) {
using TSmallInt = ::NPrivate::TUnderlyingTypeOrSelf<TSmall>;
using TLargeInt = ::NPrivate::TUnderlyingTypeOrSelf<TLarge>;
if (std::is_unsigned<TSmallInt>::value && std::is_signed<TLargeInt>::value) {
if (IsNegative(largeInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>()
- << "', negative value converted to unsigned";
+ << TypeName<TSmallInt>()
+ << "', negative value converted to unsigned";
}
}
@@ -129,14 +129,14 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
if (IsNegative(smallInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>()
- << "', positive value converted to negative";
+ << TypeName<TSmallInt>()
+ << "', positive value converted to negative";
}
}
if (TLargeInt(smallInt) != largeInt) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>() << "', loss of data";
+ << TypeName<TSmallInt>() << "', loss of data";
}
return static_cast<TSmall>(smallInt);
@@ -147,17 +147,17 @@ inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept {
try {
return SafeIntegerCast<TSmallInt>(largeInt);
} catch (const yexception& exc) {
- Y_FAIL("IntegerCast: %s", exc.what());
+ Y_FAIL("IntegerCast: %s", exc.what());
}
}
-
-/* Convert given enum value to its underlying type. This is just a shortcut for
- * `static_cast<std::underlying_type_t<EEnum>>(enum_)`.
- */
-template <typename T>
-constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept {
- return static_cast<std::underlying_type_t<T>>(enum_);
-}
+
+/* Convert given enum value to its underlying type. This is just a shortcut for
+ * `static_cast<std::underlying_type_t<EEnum>>(enum_)`.
+ */
+template <typename T>
+constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept {
+ return static_cast<std::underlying_type_t<T>>(enum_);
+}
// std::bit_cast from c++20
template <class TTarget, class TSource>
diff --git a/util/generic/cast_ut.cpp b/util/generic/cast_ut.cpp
index 718a8de79d..0ab58f2efc 100644
--- a/util/generic/cast_ut.cpp
+++ b/util/generic/cast_ut.cpp
@@ -7,7 +7,7 @@ class TGenericCastsTest: public TTestBase {
UNIT_TEST(TestVerifyDynamicCast)
UNIT_TEST(TestIntegralCast)
UNIT_TEST(TestEnumCast)
- UNIT_TEST(TestToUnderlying)
+ UNIT_TEST(TestToUnderlying)
UNIT_TEST(TestBitCast)
UNIT_TEST_SUITE_END();
@@ -55,32 +55,32 @@ private:
UNIT_ASSERT(SafeIntegerCast<B>(-1) == BM1);
UNIT_ASSERT(SafeIntegerCast<C>(1) == C::CM1);
}
-
- void TestToUnderlying() {
- enum A {
- AM1 = -1
- };
-
+
+ void TestToUnderlying() {
+ enum A {
+ AM1 = -1
+ };
+
enum B: int {
- BM1 = -1
- };
-
+ BM1 = -1
+ };
+
enum class C: unsigned short {
- CM1 = 1
- };
-
- static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), "");
- static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), "");
- static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), "");
-
- static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, "");
- static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, "");
- static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, "");
-
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1));
- }
+ CM1 = 1
+ };
+
+ static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), "");
+ static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), "");
+ static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), "");
+
+ static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, "");
+ static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, "");
+ static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, "");
+
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1));
+ }
void TestBitCast() {
// Change sign of float
diff --git a/util/generic/explicit_type.h b/util/generic/explicit_type.h
index 34e269f155..e43b8455f7 100644
--- a/util/generic/explicit_type.h
+++ b/util/generic/explicit_type.h
@@ -24,7 +24,7 @@ template <class T>
class TExplicitType {
public:
template <class OtherT>
- TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept
+ TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept
: Value_(value)
{
}
diff --git a/util/generic/explicit_type_ut.cpp b/util/generic/explicit_type_ut.cpp
index 50a745f090..2811e789f2 100644
--- a/util/generic/explicit_type_ut.cpp
+++ b/util/generic/explicit_type_ut.cpp
@@ -38,8 +38,8 @@ struct IntConstructible {
}
};
-Y_UNIT_TEST_SUITE(TestExplicitType) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestExplicitType) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, char>::Result), true);
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, int>::Result), false);
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, wchar_t>::Result), false);
diff --git a/util/generic/fastqueue.h b/util/generic/fastqueue.h
index 1fee5b86f6..6f01fec4d6 100644
--- a/util/generic/fastqueue.h
+++ b/util/generic/fastqueue.h
@@ -27,7 +27,7 @@ public:
}
inline T Pop() {
- Y_ASSERT(!this->Empty());
+ Y_ASSERT(!this->Empty());
THolder<THelper> tmp(Queue_.PopBack());
--Size_;
diff --git a/util/generic/flags.cpp b/util/generic/flags.cpp
index 2ee52188a0..f16a643562 100644
--- a/util/generic/flags.cpp
+++ b/util/generic/flags.cpp
@@ -3,26 +3,26 @@
#include <util/stream/format.h>
#include <util/system/yassert.h>
-void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) {
+void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) {
/* Note that this function is in cpp because we need to break circular
* dependency between TFlags and ENumberFormat. */
stream << "TFlags(";
switch (size) {
- case 1:
- stream << Bin(static_cast<ui8>(value), HF_FULL);
- break;
- case 2:
- stream << Bin(static_cast<ui16>(value), HF_FULL);
- break;
- case 4:
- stream << Bin(static_cast<ui32>(value), HF_FULL);
- break;
- case 8:
- stream << Bin(static_cast<ui64>(value), HF_FULL);
- break;
- default:
- Y_VERIFY(false);
+ case 1:
+ stream << Bin(static_cast<ui8>(value), HF_FULL);
+ break;
+ case 2:
+ stream << Bin(static_cast<ui16>(value), HF_FULL);
+ break;
+ case 4:
+ stream << Bin(static_cast<ui32>(value), HF_FULL);
+ break;
+ case 8:
+ stream << Bin(static_cast<ui64>(value), HF_FULL);
+ break;
+ default:
+ Y_VERIFY(false);
}
stream << ")";
diff --git a/util/generic/flags.h b/util/generic/flags.h
index a1f5921d42..3b0eb4a2e2 100644
--- a/util/generic/flags.h
+++ b/util/generic/flags.h
@@ -6,9 +6,9 @@
#include <util/generic/typetraits.h>
#include <util/generic/fwd.h>
-class IOutputStream;
+class IOutputStream;
namespace NPrivate {
- void PrintFlags(IOutputStream& stream, ui64 value, size_t size);
+ void PrintFlags(IOutputStream& stream, ui64 value, size_t size);
}
/**
@@ -34,10 +34,10 @@ namespace NPrivate {
template <class Enum>
class TFlags {
static_assert(std::is_enum<Enum>::value, "Expecting an enumeration here.");
-
+
public:
using TEnum = Enum;
- using TInt = std::underlying_type_t<Enum>;
+ using TInt = std::underlying_type_t<Enum>;
constexpr TFlags(std::nullptr_t = 0)
: Value_(0)
@@ -79,18 +79,18 @@ public:
return TFlags(TFlag(l.Value_ ^ r.Value_));
}
- constexpr friend TFlags
- operator^(TEnum l, TFlags r) {
+ constexpr friend TFlags
+ operator^(TEnum l, TFlags r) {
return TFlags(TFlag(static_cast<TInt>(l) ^ r.Value_));
}
- constexpr friend TFlags
- operator^(TFlags l, TEnum r) {
+ constexpr friend TFlags
+ operator^(TFlags l, TEnum r) {
return TFlags(TFlag(l.Value_ ^ static_cast<TInt>(r)));
}
- constexpr friend TFlags
- operator&(TFlags l, TFlags r) {
+ constexpr friend TFlags
+ operator&(TFlags l, TFlags r) {
return TFlags(TFlag(l.Value_ & r.Value_));
}
@@ -177,7 +177,7 @@ public:
return *this;
}
- friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) {
+ friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) {
::NPrivate::PrintFlags(stream, static_cast<ui64>(flags.Value_), sizeof(TInt));
return stream;
}
diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp
index 5377c6a058..9290f55099 100644
--- a/util/generic/flags_ut.cpp
+++ b/util/generic/flags_ut.cpp
@@ -31,7 +31,7 @@ namespace {
Y_DECLARE_OPERATORS_FOR_FLAGS(ETestFlags3)
}
-Y_UNIT_TEST_SUITE(TFlagsTest) {
+Y_UNIT_TEST_SUITE(TFlagsTest) {
template <class Enum>
void TestEnum() {
{
@@ -66,12 +66,12 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
}
}
- Y_UNIT_TEST(TestFlags) {
+ Y_UNIT_TEST(TestFlags) {
TestEnum<ETestFlag1>();
TestEnum<ETestFlag2>();
}
- Y_UNIT_TEST(TestZero) {
+ Y_UNIT_TEST(TestZero) {
/* This code should simply compile. */
ETest1 f = 0;
@@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
ff = 0;
}
- Y_UNIT_TEST(TestOutput) {
+ Y_UNIT_TEST(TestOutput) {
ETest1 value0 = nullptr, value1 = Test1, value7 = Test1 | Test2 | Test4;
UNIT_ASSERT_VALUES_EQUAL(ToString(value0), "TFlags(0000000000000000)");
@@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(value7), "TFlags(0000000000000111)");
}
- Y_UNIT_TEST(TestHash) {
+ Y_UNIT_TEST(TestHash) {
ETest1 value0 = nullptr, value1 = Test1;
THashMap<ETest1, int> hash;
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
UNIT_ASSERT_VALUES_EQUAL(hash[value1], 1);
}
- Y_UNIT_TEST(TestBaseType) {
+ Y_UNIT_TEST(TestBaseType) {
ui16 goodValue = 7;
auto goodFlags = ETest1::FromBaseType(goodValue);
UNIT_ASSERT(goodFlags& ETestFlag1::Test1);
diff --git a/util/generic/function_ut.cpp b/util/generic/function_ut.cpp
index 3880295a9f..730d2dc7de 100644
--- a/util/generic/function_ut.cpp
+++ b/util/generic/function_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestFunctionSignature) {
+Y_UNIT_TEST_SUITE(TestFunctionSignature) {
int FF(double x) {
return (int)x;
}
@@ -18,15 +18,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
}
};
- Y_UNIT_TEST(TestPlainFunc) {
+ Y_UNIT_TEST(TestPlainFunc) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(FF)>, decltype(FF));
}
- Y_UNIT_TEST(TestMethod) {
+ Y_UNIT_TEST(TestMethod) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(&A::F)>, decltype(FF));
}
- Y_UNIT_TEST(TestLambda) {
+ Y_UNIT_TEST(TestLambda) {
auto f = [](double x) -> int {
return FF(x);
};
@@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF));
}
- Y_UNIT_TEST(TestFunction) {
+ Y_UNIT_TEST(TestFunction) {
std::function<int(double)> f(FF);
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF));
@@ -51,15 +51,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
#undef FA
}
- Y_UNIT_TEST(TestTypeErasureTraits) {
+ Y_UNIT_TEST(TestTypeErasureTraits) {
TestCT<std::function<int(double, char)>>();
}
- Y_UNIT_TEST(TestPlainFunctionTraits) {
+ Y_UNIT_TEST(TestPlainFunctionTraits) {
TestCT<decltype(FFF)>();
}
- Y_UNIT_TEST(TestLambdaTraits) {
+ Y_UNIT_TEST(TestLambdaTraits) {
auto fff = [](double xx, char xxx) -> int {
return FFF(xx, xxx);
};
diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp
index 0a0293f795..b5ad0813e3 100644
--- a/util/generic/fuzz/vector/main.cpp
+++ b/util/generic/fuzz/vector/main.cpp
@@ -2,7 +2,7 @@
#include <util/stream/mem.h>
template <class T>
-static inline T Read(IInputStream& in) {
+static inline T Read(IInputStream& in) {
T t;
in.LoadOrFail(&t, sizeof(t));
diff --git a/util/generic/fwd.h b/util/generic/fwd.h
index 5cc2da40e5..53766a91fa 100644
--- a/util/generic/fwd.h
+++ b/util/generic/fwd.h
@@ -99,8 +99,8 @@ class TBitMap;
//autopointers
class TDelete;
-class TDeleteArray;
-class TFree;
+class TDeleteArray;
+class TFree;
class TCopyNew;
template <class T, class D = TDelete>
@@ -112,57 +112,57 @@ class THolder;
template <class T, class C, class D = TDelete>
class TRefCounted;
-template <class T>
-class TDefaultIntrusivePtrOps;
-
+template <class T>
+class TDefaultIntrusivePtrOps;
+
template <class T, class Ops>
-class TSimpleIntrusiveOps;
-
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+class TSimpleIntrusiveOps;
+
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
class TIntrusivePtr;
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
-class TIntrusiveConstPtr;
-
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
-using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>;
-
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+class TIntrusiveConstPtr;
+
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>;
+
template <class T, class C, class D = TDelete>
class TSharedPtr;
template <class T, class C = TCopyNew, class D = TDelete>
class TCopyPtr;
-template <class TPtr, class TCopy = TCopyNew>
-class TCowPtr;
-
-template <typename T>
-class TPtrArg;
-
-template <typename T>
-using TArrayHolder = THolder<T, TDeleteArray>;
-
-template <typename T>
-using TMallocHolder = THolder<T, TFree>;
-
-template <typename T>
-using TArrayPtr = TAutoPtr<T, TDeleteArray>;
-
-template <typename T>
-using TMallocPtr = TAutoPtr<T, TFree>;
-
+template <class TPtr, class TCopy = TCopyNew>
+class TCowPtr;
+
+template <typename T>
+class TPtrArg;
+
+template <typename T>
+using TArrayHolder = THolder<T, TDeleteArray>;
+
+template <typename T>
+using TMallocHolder = THolder<T, TFree>;
+
+template <typename T>
+using TArrayPtr = TAutoPtr<T, TDeleteArray>;
+
+template <typename T>
+using TMallocPtr = TAutoPtr<T, TFree>;
+
//maybe
namespace NMaybe {
struct TPolicyUndefinedExcept;
}
-
+
template <class T, class Policy = ::NMaybe::TPolicyUndefinedExcept>
class TMaybe;
-
-struct TGUID;
-
-template <class T>
-class TArrayRef;
-
-template <class T>
-using TConstArrayRef = TArrayRef<const T>;
+
+struct TGUID;
+
+template <class T>
+class TArrayRef;
+
+template <class T>
+using TConstArrayRef = TArrayRef<const T>;
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index 8b907457bc..c403c9b182 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -87,7 +87,7 @@ static bool GetDigit(const char c, ui32& digit) {
return true;
}
-bool GetGuid(const TStringBuf s, TGUID& result) {
+bool GetGuid(const TStringBuf s, TGUID& result) {
size_t partId = 0;
ui64 partValue = 0;
bool isEmptyPart = true;
@@ -129,7 +129,7 @@ bool GetGuid(const TStringBuf s, TGUID& result) {
// Parses GUID from s and checks that it's valid.
// In case of error returns TGUID().
-TGUID GetGuid(const TStringBuf s) {
+TGUID GetGuid(const TStringBuf s) {
TGUID result;
if (GetGuid(s, result)) {
@@ -139,7 +139,7 @@ TGUID GetGuid(const TStringBuf s) {
return TGUID();
}
-bool GetUuid(const TStringBuf s, TGUID& result) {
+bool GetUuid(const TStringBuf s, TGUID& result) {
if (s.size() != 36) {
return false;
}
@@ -175,7 +175,7 @@ bool GetUuid(const TStringBuf s, TGUID& result) {
// Parses GUID from uuid and checks that it's valid.
// In case of error returns TGUID().
-TGUID GetUuid(const TStringBuf s) {
+TGUID GetUuid(const TStringBuf s) {
TGUID result;
if (GetUuid(s, result)) {
diff --git a/util/generic/guid.h b/util/generic/guid.h
index 2bf6c8ad99..7c1884d96e 100644
--- a/util/generic/guid.h
+++ b/util/generic/guid.h
@@ -1,7 +1,7 @@
#pragma once
-#include "fwd.h"
-
+#include "fwd.h"
+
#include <util/str_stl.h>
/**
@@ -15,13 +15,13 @@
* and https://st.yandex-team.ru/IGNIETFERRO-768 for details.
*/
struct TGUID {
- ui32 dw[4] = {};
+ ui32 dw[4] = {};
- constexpr bool IsEmpty() const noexcept {
+ constexpr bool IsEmpty() const noexcept {
return (dw[0] | dw[1] | dw[2] | dw[3]) == 0;
}
- constexpr explicit operator bool() const noexcept {
+ constexpr explicit operator bool() const noexcept {
return !IsEmpty();
}
@@ -44,23 +44,23 @@ struct TGUID {
static TGUID CreateTimebased();
};
-constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept {
- return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3];
+constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept {
+ return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3];
}
-constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept {
+constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept {
return !(a == b);
}
struct TGUIDHash {
- constexpr int operator()(const TGUID& a) const noexcept {
+ constexpr int operator()(const TGUID& a) const noexcept {
return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3];
}
};
template <>
struct THash<TGUID> {
- constexpr size_t operator()(const TGUID& g) const noexcept {
+ constexpr size_t operator()(const TGUID& g) const noexcept {
return (unsigned int)TGUIDHash()(g);
}
};
@@ -68,12 +68,12 @@ struct THash<TGUID> {
void CreateGuid(TGUID* res);
TString GetGuidAsString(const TGUID& g);
TString CreateGuidAsString();
-TGUID GetGuid(TStringBuf s);
-bool GetGuid(TStringBuf s, TGUID& result);
+TGUID GetGuid(TStringBuf s);
+bool GetGuid(TStringBuf s, TGUID& result);
/**
* Functions for correct parsing RFC4122 GUID, which described in
* https://en.wikipedia.org/wiki/Universally_unique_identifier
**/
-TGUID GetUuid(TStringBuf s);
-bool GetUuid(TStringBuf s, TGUID& result);
+TGUID GetUuid(TStringBuf s);
+bool GetUuid(TStringBuf s, TGUID& result);
diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp
index 048354ff39..b9c974b072 100644
--- a/util/generic/guid_ut.cpp
+++ b/util/generic/guid_ut.cpp
@@ -2,7 +2,7 @@
#include "guid.h"
-Y_UNIT_TEST_SUITE(TGuidTest) {
+Y_UNIT_TEST_SUITE(TGuidTest) {
//TODO - make real constructor
static TGUID Construct(ui32 d1, ui32 d2, ui32 d3, ui32 d4) {
TGUID ret;
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
TString S;
};
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
for (size_t i = 0; i < 1000; ++i) {
TGUID g;
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
}
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
const TTest tests[] = {
{Construct(1, 1, 1, 1), "1-1-1-1"},
{Construct(0, 0, 0, 0), "0-0-0-0"},
@@ -60,19 +60,19 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
{Construct(0, 0, 0, 0), "000000000000-000000000000000000000000000000000000000-000-0"},
};
- for (const auto& t : tests) {
+ for (const auto& t : tests) {
UNIT_ASSERT_EQUAL(t.G, GetGuid(t.S));
}
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
//if this test failed, please, fix buffer size in GetGuidAsString()
TGUID max = Construct(Max<ui32>(), Max<ui32>(), Max<ui32>(), Max<ui32>());
UNIT_ASSERT_EQUAL(GetGuidAsString(max).length(), 35);
}
- Y_UNIT_TEST(Test4) {
+ Y_UNIT_TEST(Test4) {
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 4)), "1-2-3-4");
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 0xFFFFFF, 4)), "1-2-ffffff-4");
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(0xFAFA, 2, 3, 4)), "fafa-2-3-4");
@@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 0xDEAD)), "1-2-3-dead");
}
- Y_UNIT_TEST(Test5) {
+ Y_UNIT_TEST(Test5) {
const TTest tests[] = {
{TGUID(), "1-1-1-1-1"},
{TGUID(), "00000001-0001-0001-0001-00000000001-"},
diff --git a/util/generic/hash.h b/util/generic/hash.h
index e46db21fa9..3375f61689 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -223,17 +223,17 @@ public:
_yhashtable_buckets(const Alloc& other)
: base_type(other)
- , Data(nullptr)
+ , Data(nullptr)
, Size()
{
}
~_yhashtable_buckets() {
- Y_ASSERT(!Data);
+ Y_ASSERT(!Data);
}
void initialize_dynamic(TBucketDivisor size) {
- Y_ASSERT(!Data);
+ Y_ASSERT(!Data);
Data = this->_get_alloc().allocate(size() + 2) + 1;
Size = size;
@@ -242,7 +242,7 @@ public:
}
void deinitialize_dynamic() {
- Y_ASSERT(Data);
+ Y_ASSERT(Data);
this->_get_alloc().deallocate(Data - 1, *reinterpret_cast<size_type*>(Data - 1));
Data = pointer();
@@ -257,7 +257,7 @@ public:
}
void deinitialize_static() {
- Y_ASSERT(Data);
+ Y_ASSERT(Data);
Data = pointer();
Size = TBucketDivisor();
@@ -500,7 +500,7 @@ private:
node* get_node() {
node* result = this->_get_alloc().allocate(1);
- Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */
+ Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */
return result;
}
void put_node(node* p) {
@@ -640,7 +640,7 @@ public:
}
iterator end() {
- return iterator(nullptr);
+ return iterator(nullptr);
} /*y*/
const_iterator begin() const {
@@ -651,7 +651,7 @@ public:
}
const_iterator end() const {
- return const_iterator(nullptr);
+ return const_iterator(nullptr);
} /*y*/
public:
@@ -767,7 +767,7 @@ public:
node* first;
for (first = buckets[n];
first && !equals(get_key(first->val), key);
- first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
+ first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
{
}
return iterator(first); /*y*/
@@ -779,7 +779,7 @@ public:
const node* first;
for (first = buckets[n];
first && !equals(get_key(first->val), key);
- first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
+ first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
{
}
return const_iterator(first); /*y*/
@@ -839,7 +839,7 @@ public:
// implemented in save_stl.h
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const;
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const;
void clear(size_type downsize) {
basic_clear();
@@ -956,13 +956,13 @@ private:
template <class V>
__yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() {
- Y_ASSERT(cur);
+ Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
node** bucket = (node**)((uintptr_t)cur & ~1);
- while (*bucket == nullptr)
+ while (*bucket == nullptr)
++bucket;
- Y_ASSERT(*bucket != nullptr);
+ Y_ASSERT(*bucket != nullptr);
cur = (node*)((uintptr_t)*bucket & ~1);
}
return *this;
@@ -977,13 +977,13 @@ inline __yhashtable_iterator<V> __yhashtable_iterator<V>::operator++(int) {
template <class V>
__yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() {
- Y_ASSERT(cur);
+ Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
node** bucket = (node**)((uintptr_t)cur & ~1);
- while (*bucket == nullptr)
+ while (*bucket == nullptr)
++bucket;
- Y_ASSERT(*bucket != nullptr);
+ Y_ASSERT(*bucket != nullptr);
cur = (node*)((uintptr_t)*bucket & ~1);
}
return *this;
@@ -1166,7 +1166,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
}
}
if (equals(get_key(first->val), key)) {
- buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
+ buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
++erased;
--num_elements;
delete_node(first);
@@ -1196,7 +1196,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
}
}
if (equals(get_key(first->val), key)) {
- buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
+ buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
--num_elements;
delete_node(first);
return 1;
@@ -1212,7 +1212,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) {
node* cur = buckets[n];
if (cur == p) {
- buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/
+ buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/
delete_node(cur);
--num_elements;
} else {
@@ -1280,7 +1280,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
while (first) {
size_type new_bucket = bkt_num(first->val, n);
node* next = first->next;
- buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/
+ buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/
next = tmp[new_bucket];
first->next = next ? next : (node*)((uintptr_t) & (tmp[new_bucket + 1]) | 1); /*y*/
tmp[new_bucket] = first;
@@ -1298,7 +1298,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
while (tmp[bucket]) {
node* next = tmp[bucket]->next;
delete_node(tmp[bucket]);
- tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/;
+ tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/;
}
}
throw;
@@ -1356,7 +1356,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
delete_node(cur);
cur = next;
}
- *first = nullptr;
+ *first = nullptr;
}
}
num_elements = 0;
@@ -1364,7 +1364,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
template <class V, class K, class HF, class Ex, class Eq, class A>
void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) {
- Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty());
+ Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty());
#ifdef __STL_USE_EXCEPTIONS
try {
@@ -1637,7 +1637,7 @@ public:
template <class TKey>
T& operator[](const TKey& key) {
- insert_ctx ctx = nullptr;
+ insert_ctx ctx = nullptr;
iterator it = find(key, ctx);
if (it != end()) {
@@ -1712,7 +1712,7 @@ public:
// if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count()
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
return rep.template save_for_st<KeySaver>(stream, ks, stHash);
}
@@ -1978,7 +1978,7 @@ public:
// if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count()
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
return rep.template save_for_st<KeySaver>(stream, ks, stHash);
}
diff --git a/util/generic/hash_primes_ut.cpp b/util/generic/hash_primes_ut.cpp
index 7b5bf8b5c9..31ae562af3 100644
--- a/util/generic/hash_primes_ut.cpp
+++ b/util/generic/hash_primes_ut.cpp
@@ -6,8 +6,8 @@
#include <util/string/builder.h>
#include <util/random/fast.h>
-Y_UNIT_TEST_SUITE(TestHashPrimes) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestHashPrimes) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(1), 7);
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(6), 7);
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(7), 7);
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h
index e8088cf23b..8da03fd597 100644
--- a/util/generic/hash_set.h
+++ b/util/generic/hash_set.h
@@ -241,7 +241,7 @@ public:
}
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks) const {
return rep.template save_for_st<KeySaver>(stream, ks);
}
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 0551d58770..060d617650 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -57,7 +57,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestHMMapInitializerList);
UNIT_TEST(TestHSetInitializerList);
UNIT_TEST(TestHMSetInitializerList);
- UNIT_TEST(TestHSetInsertInitializerList);
+ UNIT_TEST(TestHSetInsertInitializerList);
UNIT_TEST(TestTupleHash);
UNIT_TEST_SUITE_END();
@@ -108,7 +108,7 @@ protected:
void TestHMMapInitializerList();
void TestHSetInitializerList();
void TestHMSetInitializerList();
- void TestHSetInsertInitializerList();
+ void TestHSetInsertInitializerList();
void TestTupleHash();
};
@@ -798,7 +798,7 @@ public:
TCountingAllocator(TAllocatorCounters* counters)
: Counters_(counters)
{
- Y_ASSERT(counters);
+ Y_ASSERT(counters);
}
template <class Other>
@@ -1187,44 +1187,44 @@ void THashTest::TestHMSetInitializerList() {
h2.insert("baz");
UNIT_ASSERT_EQUAL(h1, h2);
}
-
-namespace {
- struct TFoo {
- int A;
- int B;
-
+
+namespace {
+ struct TFoo {
+ int A;
+ int B;
+
bool operator==(const TFoo& o) const {
- return A == o.A && B == o.B;
- }
- };
-}
-
-template <>
-struct THash<TFoo> {
- size_t operator()(const TFoo& v) const {
- return v.A ^ v.B;
- }
-};
-
-template <>
-void Out<TFoo>(IOutputStream& o, const TFoo& v) {
- o << '{' << v.A << ';' << v.B << '}';
-}
-
-void THashTest::TestHSetInsertInitializerList() {
- {
+ return A == o.A && B == o.B;
+ }
+ };
+}
+
+template <>
+struct THash<TFoo> {
+ size_t operator()(const TFoo& v) const {
+ return v.A ^ v.B;
+ }
+};
+
+template <>
+void Out<TFoo>(IOutputStream& o, const TFoo& v) {
+ o << '{' << v.A << ';' << v.B << '}';
+}
+
+void THashTest::TestHSetInsertInitializerList() {
+ {
const THashSet<int> x = {1};
THashSet<int> y;
- y.insert({1});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({1});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<int> x = {1, 2};
THashSet<int> y;
- y.insert({1, 2});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({1, 2});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<int> x = {1, 2, 3, 4, 5};
THashSet<int> y;
y.insert({
@@ -1234,21 +1234,21 @@ void THashTest::TestHSetInsertInitializerList() {
4,
5,
});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<TFoo> x = {{1, 2}};
THashSet<TFoo> y;
- y.insert({{1, 2}});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({{1, 2}});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<TFoo> x = {{1, 2}, {3, 4}};
THashSet<TFoo> y;
- y.insert({{1, 2}, {3, 4}});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
-}
+ y.insert({{1, 2}, {3, 4}});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+}
/*
* Sequence for MultiHash is reversed as it calculates hash as
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index b5d3f2051b..93112c37f7 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -332,11 +332,11 @@ public:
TIntrusiveList temp;
temp.Append(right);
- Y_ASSERT(right.Empty());
+ Y_ASSERT(right.Empty());
right.Append(*this);
- Y_ASSERT(this->Empty());
+ Y_ASSERT(this->Empty());
this->Append(temp);
- Y_ASSERT(temp.Empty());
+ Y_ASSERT(temp.Empty());
}
public:
@@ -823,12 +823,12 @@ public:
}
inline T* Front() noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
return Begin_->Node();
}
inline const T* Front() const noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
return Begin_->Node();
}
@@ -838,7 +838,7 @@ public:
}
inline T* PopFront() noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
TListItem* const ret = Begin_;
Begin_ = Begin_->Next();
diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp
index eff7cdf2ee..96a7b19e07 100644
--- a/util/generic/intrlist_ut.cpp
+++ b/util/generic/intrlist_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
class TListTest: public TTestBase {
UNIT_TEST_SUITE(TListTest);
diff --git a/util/generic/is_in.h b/util/generic/is_in.h
index 4f175ea5eb..acfd5ec350 100644
--- a/util/generic/is_in.h
+++ b/util/generic/is_in.h
@@ -12,9 +12,9 @@ template <class C, class T>
static inline bool IsIn(const C& c, const T& e);
namespace NIsInHelper {
- Y_HAS_MEMBER(find, FindMethod);
- Y_HAS_SUBTYPE(const_iterator, ConstIterator);
- Y_HAS_SUBTYPE(key_type, KeyType);
+ Y_HAS_MEMBER(find, FindMethod);
+ Y_HAS_SUBTYPE(const_iterator, ConstIterator);
+ Y_HAS_SUBTYPE(key_type, KeyType);
template <class T>
using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>;
@@ -44,7 +44,7 @@ static inline bool IsIn(I f, I l, const T& v) {
template <class C, class T>
static inline bool IsIn(const C& c, const T& e) {
using namespace NIsInHelper;
- return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e);
+ return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e);
}
template <class T, class U>
diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp
index c668bce807..b60f7a8239 100644
--- a/util/generic/is_in_ut.cpp
+++ b/util/generic/is_in_ut.cpp
@@ -9,7 +9,7 @@
#include "strbuf.h"
#include "string.h"
-Y_UNIT_TEST_SUITE(TIsIn) {
+Y_UNIT_TEST_SUITE(TIsIn) {
template <class TCont, class T>
void TestIsInWithCont(const T& elem) {
class TMapMock: public TCont {
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
m.FindCalled = 0;
}
- Y_UNIT_TEST(IsInTest) {
+ Y_UNIT_TEST(IsInTest) {
TestIsInWithCont<TMap<TString, TString>>(std::make_pair("found", "1"));
TestIsInWithCont<TMultiMap<TString, TString>>(std::make_pair("found", "1"));
TestIsInWithCont<THashMap<TString, TString>>(std::make_pair("found", "1"));
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(!IsIn(b, 'z'));
}
- Y_UNIT_TEST(IsInInitListTest) {
+ Y_UNIT_TEST(IsInInitListTest) {
const char* abc = "abc";
const char* def = "def";
@@ -94,9 +94,9 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3}));
}
- Y_UNIT_TEST(ConfOfTest) {
- UNIT_ASSERT(IsIn({1, 2, 3}, 1));
- UNIT_ASSERT(!IsIn({1, 2, 3}, 4));
+ Y_UNIT_TEST(ConfOfTest) {
+ UNIT_ASSERT(IsIn({1, 2, 3}, 1));
+ UNIT_ASSERT(!IsIn({1, 2, 3}, 4));
const TString b = "b";
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index 19e9d20976..21fa5d781d 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -1,6 +1,6 @@
#pragma once
-#include <iterator>
+#include <iterator>
#include <utility>
namespace NStlIterator {
@@ -130,10 +130,10 @@ public:
/**
* Transform given reverse iterator into forward iterator pointing to the same element.
- *
+ *
* @see http://stackoverflow.com/a/1830240
- */
+ */
template <class TIterator>
auto ToForwardIterator(TIterator iter) {
- return std::next(iter).base();
+ return std::next(iter).base();
}
diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp
index a7e3670ae1..fa6cb3c0ad 100644
--- a/util/generic/iterator_range_ut.cpp
+++ b/util/generic/iterator_range_ut.cpp
@@ -4,8 +4,8 @@
#include <util/generic/algorithm.h>
#include <util/generic/vector.h>
-Y_UNIT_TEST_SUITE(IteratorRange) {
- Y_UNIT_TEST(DefaultConstructor) {
+Y_UNIT_TEST_SUITE(IteratorRange) {
+ Y_UNIT_TEST(DefaultConstructor) {
TIteratorRange<int*> range;
UNIT_ASSERT(range.empty());
}
@@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT(range.empty());
}
- Y_UNIT_TEST(RangeBasedForLoop) {
+ Y_UNIT_TEST(RangeBasedForLoop) {
// compileability test
for (int i : TIteratorRange<int*>()) {
Y_UNUSED(i);
@@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
}
}
- Y_UNIT_TEST(Works) {
+ Y_UNIT_TEST(Works) {
const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values));
UNIT_ASSERT_VALUES_EQUAL(range.size(), Y_ARRAY_SIZE(values));
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT_VALUES_EQUAL(i, 10);
}
- Y_UNIT_TEST(OperatorsAndReferences) {
+ Y_UNIT_TEST(OperatorsAndReferences) {
TVector<size_t> values{1, 2, 3, 4, 5};
auto range = MakeIteratorRange(values.begin(), values.end());
UNIT_ASSERT_VALUES_EQUAL(range[2], 3);
@@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT_VALUES_EQUAL(rangeBVector[6], false);
}
- Y_UNIT_TEST(CanUseInAlgorithms) {
+ Y_UNIT_TEST(CanUseInAlgorithms) {
const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values));
// more like compileability test
diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp
index 00be19e10e..068dcb5f9b 100644
--- a/util/generic/iterator_ut.cpp
+++ b/util/generic/iterator_ut.cpp
@@ -2,11 +2,11 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TIterator) {
- Y_UNIT_TEST(ToForwardIteratorTest) {
+Y_UNIT_TEST_SUITE(TIterator) {
+ Y_UNIT_TEST(ToForwardIteratorTest) {
TVector<int> x = {1, 2};
- UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin()));
- UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
+ UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin()));
+ UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
}
}
diff --git a/util/generic/lazy_value.h b/util/generic/lazy_value.h
index 3c720f76b5..49aa46bee3 100644
--- a/util/generic/lazy_value.h
+++ b/util/generic/lazy_value.h
@@ -39,7 +39,7 @@ public:
}
void InitDefault() const {
- Y_ASSERT(Initializer);
+ Y_ASSERT(Initializer);
ValueHolder = Initializer();
}
diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp
index f6135880c3..8d9cb49673 100644
--- a/util/generic/lazy_value_ut.cpp
+++ b/util/generic/lazy_value_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
- Y_UNIT_TEST(TestLazyValue) {
+Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
+ Y_UNIT_TEST(TestLazyValue) {
TLazyValue<int> value([]() {
return 5;
});
@@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT(value);
}
- Y_UNIT_TEST(TestLazyValueInitialization) {
+ Y_UNIT_TEST(TestLazyValueInitialization) {
TLazyValue<int> value1([]() { return 5; });
TLazyValue<int> value2 = []() { return 5; };
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
copy1 = value2;
}
- Y_UNIT_TEST(TestLazyValueCopy) {
+ Y_UNIT_TEST(TestLazyValueCopy) {
TLazyValue<int> value([]() { return 5; });
UNIT_ASSERT(!value);
@@ -113,13 +113,13 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
size_t TValueProvider::CountParseDataCalled = 0;
- Y_UNIT_TEST(TestValueProvider) {
+ Y_UNIT_TEST(TestValueProvider) {
TValueProvider provider;
UNIT_ASSERT(provider.GetData() == "hi");
}
- Y_UNIT_TEST(TestValueProviderCopy) {
+ Y_UNIT_TEST(TestValueProviderCopy) {
TValueProvider provider;
provider.GetData();
const auto countParsed = TValueProvider::CountParseDataCalled;
@@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT_EQUAL(countParsed, TValueProvider::CountParseDataCalled);
}
- Y_UNIT_TEST(TestEmptyProviderCopy) {
+ Y_UNIT_TEST(TestEmptyProviderCopy) {
TValueProvider provider;
TValueProvider copy(provider);
@@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT_EQUAL(countParsed + 2, TValueProvider::CountParseDataCalled);
}
- Y_UNIT_TEST(TestMakeLazy) {
+ Y_UNIT_TEST(TestMakeLazy) {
auto lv = MakeLazy([] {
return 100500;
});
diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp
index 9e60ecf01b..3d97b66b60 100644
--- a/util/generic/list_ut.cpp
+++ b/util/generic/list_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TYListSuite) {
- Y_UNIT_TEST(TestInitializerList) {
+Y_UNIT_TEST_SUITE(TYListSuite) {
+ Y_UNIT_TEST(TestInitializerList) {
TList<int> l = {3, 42, 6};
TList<int> expected;
expected.push_back(3);
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index 79e832b024..5f6acd181f 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -4,14 +4,14 @@
#include <util/memory/pool.h>
#include <algorithm>
-Y_UNIT_TEST_SUITE(TYMapTest) {
+Y_UNIT_TEST_SUITE(TYMapTest) {
template <typename TAlloc>
void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m);
template <typename TAlloc>
void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm);
- Y_UNIT_TEST(TestMap1) {
+ Y_UNIT_TEST(TestMap1) {
{
TMap<char, int, TLess<char>> m;
DoTestMap1(m);
@@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
}
- Y_UNIT_TEST(TestMMap1) {
+ Y_UNIT_TEST(TestMMap1) {
{
TMultiMap<char, int, TLess<char>> mm;
DoTestMMap1(mm);
@@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(count == 2);
}
- Y_UNIT_TEST(TestMMap2) {
+ Y_UNIT_TEST(TestMMap2) {
using pair_type = std::pair<const int, char>;
pair_type p1(3, 'c');
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT((*i).second == 'f');
}
- Y_UNIT_TEST(TestIterators) {
+ Y_UNIT_TEST(TestIterators) {
using int_map = TMap<int, char, TLess<int>>;
int_map imap;
@@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT((*rci).second == 'f');
}
- Y_UNIT_TEST(TestEqualRange) {
+ Y_UNIT_TEST(TestEqualRange) {
using maptype = TMap<char, int, TLess<char>>;
{
@@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
using is_transparent = void;
};
- Y_UNIT_TEST(TestTemplateMethods) {
+ Y_UNIT_TEST(TestTemplateMethods) {
{
using Container = TMap<TKey, int, TKeyCmp>;
using value = Container::value_type;
@@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(c);
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
}
@@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
};
- Y_UNIT_TEST(TestMoveComparator) {
+ Y_UNIT_TEST(TestMoveComparator) {
using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>;
TParametrizedKeyCmp direct(false);
@@ -435,8 +435,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
c.insert(std::make_pair(TKey(3), 103));
TVector<int> values;
- for (auto& i : c) {
- values.push_back(i.second);
+ for (auto& i : c) {
+ values.push_back(i.second);
}
UNIT_ASSERT_VALUES_EQUAL(values.size(), 3);
@@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
}
- Y_UNIT_TEST(TestMapInitializerList) {
+ Y_UNIT_TEST(TestMapInitializerList) {
TMap<TString, int> m = {
{"one", 1},
{"two", 2},
@@ -461,7 +461,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT_VALUES_EQUAL(m["four"], 4);
}
- Y_UNIT_TEST(TestMMapInitializerList) {
+ Y_UNIT_TEST(TestMMapInitializerList) {
TMultiMap<TString, int> mm = {
{"one", 1},
{"two", 2},
@@ -477,7 +477,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT_VALUES_EQUAL(mm, expected);
}
- Y_UNIT_TEST(TestMovePoolAlloc) {
+ Y_UNIT_TEST(TestMovePoolAlloc) {
using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>;
TMemoryPool pool(1);
diff --git a/util/generic/mapfindptr.h b/util/generic/mapfindptr.h
index bc10cac60f..e7d1b31000 100644
--- a/util/generic/mapfindptr.h
+++ b/util/generic/mapfindptr.h
@@ -14,14 +14,14 @@ template <class Map, class K>
inline auto MapFindPtr(Map& map, const K& key) {
auto i = map.find(key);
- return (i == map.end() ? nullptr : &i->second);
+ return (i == map.end() ? nullptr : &i->second);
}
template <class Map, class K>
inline auto MapFindPtr(const Map& map, const K& key) {
auto i = map.find(key);
- return (i == map.end() ? nullptr : &i->second);
+ return (i == map.end() ? nullptr : &i->second);
}
/** helper for THashMap/TMap */
diff --git a/util/generic/mapfindptr_ut.cpp b/util/generic/mapfindptr_ut.cpp
index 613da7a96b..10ed7992fe 100644
--- a/util/generic/mapfindptr_ut.cpp
+++ b/util/generic/mapfindptr_ut.cpp
@@ -7,16 +7,16 @@
#include "mapfindptr.h"
-Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
+Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
struct TTestMap: std::map<int, TString>, TMapOps<TTestMap> {};
- Y_UNIT_TEST(TestDerivedClass) {
+ Y_UNIT_TEST(TestDerivedClass) {
TTestMap a;
a[42] = "cat";
UNIT_ASSERT(a.FindPtr(42));
UNIT_ASSERT_EQUAL(*a.FindPtr(42), "cat");
- UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
+ UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
//test mutation
if (TString* p = a.FindPtr(42)) {
@@ -28,13 +28,13 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
//test const-overloaded functions too
const TTestMap& b = a;
UNIT_ASSERT(b.FindPtr(42) && *b.FindPtr(42) == "dog");
- UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
+ UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
UNIT_ASSERT_STRINGS_EQUAL(b.Value(42, "cat"), "dog");
UNIT_ASSERT_STRINGS_EQUAL(b.Value(0, "alien"), "alien");
}
- Y_UNIT_TEST(TestTemplateFind) {
+ Y_UNIT_TEST(TestTemplateFind) {
THashMap<TString, int> m;
m[TString("x")] = 2;
@@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
UNIT_ASSERT_EQUAL(*m.FindPtr(TStringBuf("x")), 2);
}
- Y_UNIT_TEST(TestValue) {
+ Y_UNIT_TEST(TestValue) {
TTestMap a;
a[1] = "lol";
@@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
UNIT_ASSERT_VALUES_EQUAL(a.Value(2, "123"), "123");
}
- Y_UNIT_TEST(TestValueRef) {
+ Y_UNIT_TEST(TestValueRef) {
TTestMap a;
a[1] = "lol";
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index 34d21aebcd..63427876da 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -6,7 +6,7 @@
#include "yexception.h"
#include <util/system/align.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/ysaveload.h>
namespace NMaybe {
@@ -386,7 +386,7 @@ public:
return Defined();
}
- void Save(IOutputStream* out) const {
+ void Save(IOutputStream* out) const {
const bool defined = Defined();
::Save<bool>(out, defined);
@@ -396,7 +396,7 @@ public:
}
}
- void Load(IInputStream* in) {
+ void Load(IInputStream* in) {
bool defined;
::Load(in, defined);
@@ -709,7 +709,7 @@ constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) {
return !(value < maybe);
}
-class IOutputStream;
+class IOutputStream;
template <class T, class TPolicy>
inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) {
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index 2c1a425c5e..c30e9d9602 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -20,7 +20,7 @@ public:
}
};
-Y_UNIT_TEST_SUITE(TMaybeTest) {
+Y_UNIT_TEST_SUITE(TMaybeTest) {
Y_UNIT_TEST(TestStatic) {
using T1 = TMaybe<int>;
static_assert(std::is_trivially_copy_constructible<T1>::value, "");
@@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
static_assert(!std::is_trivially_destructible<T4>::value, "");
}
- Y_UNIT_TEST(TestWarning) {
+ Y_UNIT_TEST(TestWarning) {
TMaybe<size_t> x;
TStringStream ss;
TString line;
@@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TTestConstructorDestructor) {
+ Y_UNIT_TEST(TTestConstructorDestructor) {
int a = 0;
int b = 0;
@@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestAssignmentClear) {
+ Y_UNIT_TEST(TestAssignmentClear) {
TMaybe<int> m5;
UNIT_ASSERT(!m5.Defined());
UNIT_ASSERT(m5.Empty());
@@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m5.Empty());
}
- Y_UNIT_TEST(TestInPlace) {
+ Y_UNIT_TEST(TestInPlace) {
TMaybe<int> m;
UNIT_ASSERT(!m);
@@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m == 7);
}
- Y_UNIT_TEST(TestMove) {
+ Y_UNIT_TEST(TestMove) {
struct TMovable {
int Flag = 0;
@@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6);
}
- Y_UNIT_TEST(TestCast) {
+ Y_UNIT_TEST(TestCast) {
// Undefined maybe casts to undefined maybe
TMaybe<short> shortMaybe;
const auto undefinedMaybe = shortMaybe.Cast<long>();
@@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef());
}
- Y_UNIT_TEST(TestGetOr) {
+ Y_UNIT_TEST(TestGetOr) {
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx"));
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy"));
@@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
>=
*/
- Y_UNIT_TEST(TestCompareEqualEmpty) {
+ Y_UNIT_TEST(TestCompareEqualEmpty) {
TMaybe<int> m1;
TMaybe<int> m2;
@@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m1 >= m2);
}
- Y_UNIT_TEST(TestCompareEqualNonEmpty) {
+ Y_UNIT_TEST(TestCompareEqualNonEmpty) {
TMaybe<int> m1{1};
TMaybe<int> m2{1};
@@ -272,7 +272,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m1 >= m2);
}
- Y_UNIT_TEST(TestCompareOneLessThanOther) {
+ Y_UNIT_TEST(TestCompareOneLessThanOther) {
TMaybe<int> m1{1};
TMaybe<int> m2{2};
@@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(m1 >= m2));
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) {
TMaybe<int> m{1};
int v{1};
@@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) {
TMaybe<int> m{1};
int v{2};
@@ -322,7 +322,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) {
TMaybe<int> m{2};
int v{1};
@@ -341,7 +341,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(v >= m));
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) {
TMaybe<int> m;
int v{1};
@@ -360,7 +360,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) {
TMaybe<int> m;
auto n = Nothing();
@@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(n >= m);
}
- Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) {
+ Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) {
TMaybe<int> m{1};
auto n = Nothing();
@@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(n >= m));
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) {
TMaybe<size_t> m{1};
unsigned int v{1};
@@ -417,7 +417,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) {
TMaybe<size_t> m{1};
unsigned int v{2};
@@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) {
TMaybe<size_t> m{2};
unsigned int v{1};
@@ -455,7 +455,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(v >= m));
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) {
TMaybe<size_t> m;
unsigned int v{1};
@@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestMakeMaybe) {
+ Y_UNIT_TEST(TestMakeMaybe) {
{
auto m1 = MakeMaybe<int>(1);
UNIT_ASSERT(*m1 == 1);
@@ -583,7 +583,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingMemberSwap) {
+ Y_UNIT_TEST(TestSwappingUsingMemberSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -624,7 +624,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) {
+ Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -665,7 +665,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingGlobalSwap) {
+ Y_UNIT_TEST(TestSwappingUsingGlobalSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -706,7 +706,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) {
+ Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -747,7 +747,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingStdSwap) {
+ Y_UNIT_TEST(TestSwappingUsingStdSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -788,28 +788,28 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
+ Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
TString s;
TStringOutput output(s);
output << TMaybe<int>();
UNIT_ASSERT_EQUAL("(empty maybe)", s);
}
- Y_UNIT_TEST(TestOutputStreamNothing) {
+ Y_UNIT_TEST(TestOutputStreamNothing) {
TString s;
TStringOutput output(s);
output << Nothing();
UNIT_ASSERT_VALUES_EQUAL("(empty maybe)", s);
}
- Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
+ Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
TString s;
TStringOutput output(s);
output << TMaybe<int>(42);
UNIT_ASSERT_EQUAL("42", s);
}
- Y_UNIT_TEST(TestMaybeCovarianceImplicit) {
+ Y_UNIT_TEST(TestMaybeCovarianceImplicit) {
struct TestStruct {
TestStruct(int value)
: Value_(value)
@@ -835,7 +835,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testMaybeEmpty.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceExplicit) {
+ Y_UNIT_TEST(TestMaybeCovarianceExplicit) {
struct TestStruct {
explicit TestStruct(int value)
: Value_(value)
@@ -853,7 +853,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testStructMaybeEmpty.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceAssign) {
+ Y_UNIT_TEST(TestMaybeCovarianceAssign) {
struct TestStruct {
explicit TestStruct(int value)
: Value_(value)
@@ -881,7 +881,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testStructMaybe.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) {
+ Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) {
struct TestStruct {
enum {
FromValue,
@@ -918,7 +918,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_EQUAL(testStructFromValue.GetRef().Value_, 23);
}
- Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) {
+ Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) {
struct TestStruct {
enum {
FromValue,
diff --git a/util/generic/mem_copy.h b/util/generic/mem_copy.h
index b68c852953..ad6c253143 100644
--- a/util/generic/mem_copy.h
+++ b/util/generic/mem_copy.h
@@ -7,10 +7,10 @@
#include <cstring>
template <class T>
-using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>;
+using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>;
template <class T>
-using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>;
+using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>;
template <class T>
static inline TIfPOD<T> MemCopy(T* to, const T* from, size_t n) noexcept {
diff --git a/util/generic/mem_copy_ut.cpp b/util/generic/mem_copy_ut.cpp
index 8b55a11cf6..891827b721 100644
--- a/util/generic/mem_copy_ut.cpp
+++ b/util/generic/mem_copy_ut.cpp
@@ -18,10 +18,10 @@ namespace {
};
}
-Y_DECLARE_PODTYPE(TB);
+Y_DECLARE_PODTYPE(TB);
-Y_UNIT_TEST_SUITE(TestMemCopy) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestMemCopy) {
+ Y_UNIT_TEST(Test1) {
char buf[] = "123";
char buf1[sizeof(buf)];
@@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
int X;
};
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
x = 0;
TA a1[5];
@@ -58,14 +58,14 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TB b1[5];
TB b2[5];
MemCopy(b2, b1, 5);
}
- Y_UNIT_TEST(Test4) {
+ Y_UNIT_TEST(Test4) {
TC c1[5];
TC c2[5];
@@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(Test5) {
+ Y_UNIT_TEST(Test5) {
struct TD {
int X;
};
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
char* tmp = nullptr;
UNIT_ASSERT(MemCopy(tmp, tmp, 0) == nullptr);
diff --git a/util/generic/objects_counter_ut.cpp b/util/generic/objects_counter_ut.cpp
index 4d5da37a56..cfa6ca6a3c 100644
--- a/util/generic/objects_counter_ut.cpp
+++ b/util/generic/objects_counter_ut.cpp
@@ -2,11 +2,11 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ObjectsCounter) {
+Y_UNIT_TEST_SUITE(ObjectsCounter) {
struct TObject: public TObjectCounter<TObject> {
};
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
TObject obj;
TVector<TObject> objects;
for (ui32 i = 0; i < 100; ++i) {
@@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) {
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 101);
}
- Y_UNIT_TEST(TestEq) {
+ Y_UNIT_TEST(TestEq) {
TObject obj;
{
TObject obj1 = obj;
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) {
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1);
}
- Y_UNIT_TEST(TestMove) {
+ Y_UNIT_TEST(TestMove) {
TObject obj;
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1);
{
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 19db0e3ec5..221519cb38 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -122,7 +122,7 @@ public:
#endif
inline explicit operator bool() const noexcept {
- return nullptr != AsT();
+ return nullptr != AsT();
}
protected:
@@ -132,7 +132,7 @@ protected:
static inline T* DoRelease(T*& t) noexcept {
T* ret = t;
- t = nullptr;
+ t = nullptr;
return ret;
}
};
@@ -141,13 +141,13 @@ template <class Base, class T>
class TPointerBase: public TPointerCommon<Base, T> {
public:
inline T& operator*() const noexcept {
- Y_ASSERT(this->AsT());
+ Y_ASSERT(this->AsT());
return *(this->AsT());
}
inline T& operator[](size_t n) const noexcept {
- Y_ASSERT(this->AsT());
+ Y_ASSERT(this->AsT());
return (this->AsT())[n];
}
@@ -253,11 +253,11 @@ public:
}
template <class U, class = TGuardConversion<T, U>>
- inline THolder(TAutoPtr<U, D> t) noexcept
- : T_(t.Release())
- {
- }
-
+ inline THolder(TAutoPtr<U, D> t) noexcept
+ : T_(t.Release())
+ {
+ }
+
inline THolder(THolder&& that) noexcept
: T_(that.Release())
{
@@ -277,7 +277,7 @@ public:
}
inline void Destroy() noexcept {
- Reset(nullptr);
+ Reset(nullptr);
}
inline T* Release() noexcept Y_WARN_UNUSED_RESULT {
@@ -379,7 +379,7 @@ public:
inline void UnRef(TAtomicBase d) noexcept {
auto resultCount = Counter_.Sub(d);
- Y_ASSERT(resultCount >= 0);
+ Y_ASSERT(resultCount >= 0);
if (resultCount == 0) {
D::Destroy(static_cast<T*>(this));
}
@@ -427,7 +427,7 @@ struct TThrRefBase: public TRefCounted<TThrRefBase, TAtomicCounter> {
*
* @warning Additional care should be taken with regard to inheritance. If used
* as a base class, @p T should either declare a virtual destructor, or be
- * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T
+ * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T
* would be called, potentially slicing the object and creating memory leaks.
*
* @note To avoid accidental inheritance when it is not originally intended,
@@ -449,31 +449,31 @@ template <class T>
class TDefaultIntrusivePtrOps {
public:
static inline void Ref(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->Ref();
}
static inline void UnRef(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->UnRef();
}
static inline void DecRef(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->DecRef();
}
static inline long RefCount(const T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
return t->RefCount();
}
};
-template <class T, class Ops>
+template <class T, class Ops>
class TIntrusivePtr: public TPointerBase<TIntrusivePtr<T, Ops>, T> {
template <class U, class O>
friend class TIntrusivePtr;
@@ -509,7 +509,7 @@ public:
}
// NOTE:
- // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately
+ // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately
// e.g.
// struct A {};
// struct B {};
@@ -611,7 +611,7 @@ struct THash<TIntrusivePtr<T, Ops>>: THash<const T*> {
};
// Behaves like TIntrusivePtr but returns const T* to prevent user from accidentally modifying the referenced object.
-template <class T, class Ops>
+template <class T, class Ops>
class TIntrusiveConstPtr: public TPointerBase<TIntrusiveConstPtr<T, Ops>, const T> {
public:
inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it.
@@ -683,7 +683,7 @@ public:
}
inline void Drop() noexcept {
- TIntrusiveConstPtr(nullptr).Swap(*this);
+ TIntrusiveConstPtr(nullptr).Swap(*this);
}
inline long RefCount() const noexcept {
@@ -698,13 +698,13 @@ public:
#endif
private:
inline void Ref() noexcept {
- if (T_ != nullptr) {
+ if (T_ != nullptr) {
Ops::Ref(T_);
}
}
inline void UnRef() noexcept {
- if (T_ != nullptr) {
+ if (T_ != nullptr) {
Ops::UnRef(T_);
}
}
@@ -773,10 +773,10 @@ private:
};
template <class T, class Ops>
-typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr;
+typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr;
template <class T, class Ops>
-typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr;
+typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr;
template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args>
[[nodiscard]] TIntrusivePtr<T, Ops> MakeIntrusive(Args&&... args) {
@@ -903,7 +903,7 @@ public:
private:
template <class X>
inline void Init(X& t) {
- C_ = !!t ? new C(1) : nullptr;
+ C_ = !!t ? new C(1) : nullptr;
T_ = t.Release();
}
@@ -968,7 +968,7 @@ public:
static inline T* Copy(T* t) {
if (t)
return t->Clone();
- return nullptr;
+ return nullptr;
}
};
@@ -978,7 +978,7 @@ public:
static inline T* Copy(T* t) {
if (t)
return new T(*t);
- return nullptr;
+ return nullptr;
}
};
@@ -1027,7 +1027,7 @@ public:
}
inline void Destroy() noexcept {
- Reset(nullptr);
+ Reset(nullptr);
}
inline void Swap(TCopyPtr& r) noexcept {
@@ -1055,7 +1055,7 @@ private:
};
// Copy-on-write pointer
-template <class TPtr, class TCopy>
+template <class TPtr, class TCopy>
class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
using T = typename TPtr::TValueType;
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index c2dcff23f6..fa4d206128 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -6,7 +6,7 @@
#include <util/generic/hash_set.h>
#include <util/generic/is_in.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/system/thread.h>
class TPointerTest: public TTestBase {
@@ -41,7 +41,7 @@ private:
struct S: public TAtomicRefCount<S> {
};
- struct TLocalThread: public ISimpleThread {
+ struct TLocalThread: public ISimpleThread {
void* ThreadProc() override {
TSimpleIntrusivePtr<S> ptr;
return nullptr;
@@ -259,23 +259,23 @@ void TPointerTest::TestAutoToHolder() {
}
UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
-
- {
- TAutoPtr<A> x(new A());
- THolder<const A> y = x;
- }
-
- UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
-
- {
+
+ {
+ TAutoPtr<A> x(new A());
+ THolder<const A> y = x;
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
+
+ {
class B1: public A {
- };
-
+ };
+
TAutoPtr<B1> x(new B1());
- THolder<A> y = x;
- }
-
- UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
+ THolder<A> y = x;
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
}
void TPointerTest::TestCopyPtr() {
diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp
index a33399e104..3bccb506b9 100644
--- a/util/generic/queue_ut.cpp
+++ b/util/generic/queue_ut.cpp
@@ -6,8 +6,8 @@
#include <utility>
-Y_UNIT_TEST_SUITE(TYQueueTest) {
- Y_UNIT_TEST(ConstructorsAndAssignments) {
+Y_UNIT_TEST_SUITE(TYQueueTest) {
+ Y_UNIT_TEST(ConstructorsAndAssignments) {
{
using container = TQueue<int>;
@@ -73,7 +73,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
}
- Y_UNIT_TEST(pqueue1) {
+ Y_UNIT_TEST(pqueue1) {
TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
@@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue2) {
+ Y_UNIT_TEST(pqueue2) {
using TPQueue = TPriorityQueue<int, TDeque<int>, TLess<int>>;
TPQueue q;
@@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue3) {
+ Y_UNIT_TEST(pqueue3) {
TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
@@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue4) {
+ Y_UNIT_TEST(pqueue4) {
TDeque<int> c;
c.push_back(42);
c.push_back(101);
@@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue1) {
+ Y_UNIT_TEST(queue1) {
TQueue<int, TList<int>> q;
q.push(42);
@@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue2) {
+ Y_UNIT_TEST(queue2) {
using TQueueType = TQueue<int>;
TQueueType q;
@@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue3) {
+ Y_UNIT_TEST(queue3) {
using TQueueType = TQueue<int>;
TQueueType q;
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index 966e853b77..9aee427990 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -74,7 +74,7 @@ public:
protected:
inline void Check() const {
- Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter");
+ Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter");
}
private:
diff --git a/util/generic/scope.h b/util/generic/scope.h
index b2c33af61e..a54ffc2644 100644
--- a/util/generic/scope.h
+++ b/util/generic/scope.h
@@ -38,28 +38,28 @@ namespace NPrivate {
};
}
-// \brief `Y_SCOPE_EXIT(captures) { body };`
-//
-// General implementaion of RAII idiom (resource acquisition is initialization). Executes
-// function upon return from the current scope.
-//
+// \brief `Y_SCOPE_EXIT(captures) { body };`
+//
+// 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.
-// @see http://drdobbs.com/184403758 for detailed motivation.
+// @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
+
+// \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`.
-//
-// Inspired by `defer` statement in languages like Swift and Go.
-//
-// \code
-// auto item = s.pop();
-// bool ok = false;
-// Y_DEFER { if (!ok) { s.push(std::move(item)); } };
-// ... try handle `item` ...
-// ok = true;
-// \endcode
+//
+// Inspired by `defer` statement in languages like Swift and Go.
+//
+// \code
+// auto item = s.pop();
+// bool ok = false;
+// Y_DEFER { if (!ok) { s.push(std::move(item)); } };
+// ... try handle `item` ...
+// ok = true;
+// \endcode
#define Y_DEFER Y_SCOPE_EXIT(&)
diff --git a/util/generic/scope_ut.cpp b/util/generic/scope_ut.cpp
index bdb434d487..d5aec0e8b6 100644
--- a/util/generic/scope_ut.cpp
+++ b/util/generic/scope_ut.cpp
@@ -3,8 +3,8 @@
#include <util/generic/ptr.h>
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ScopeToolsTest) {
- Y_UNIT_TEST(OnScopeExitTest) {
+Y_UNIT_TEST_SUITE(ScopeToolsTest) {
+ Y_UNIT_TEST(OnScopeExitTest) {
int i = 0;
{
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(ScopeToolsTest) {
UNIT_ASSERT_VALUES_EQUAL(2, i);
}
- Y_UNIT_TEST(OnScopeExitMoveTest) {
+ Y_UNIT_TEST(OnScopeExitMoveTest) {
THolder<int> i{new int{10}};
int p = 0;
diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp
index d2769d327f..6c335080c0 100644
--- a/util/generic/set_ut.cpp
+++ b/util/generic/set_ut.cpp
@@ -6,8 +6,8 @@
#include <algorithm>
-Y_UNIT_TEST_SUITE(YSetTest) {
- Y_UNIT_TEST(TestSet1) {
+Y_UNIT_TEST_SUITE(YSetTest) {
+ Y_UNIT_TEST(TestSet1) {
TSet<int, TLess<int>> s;
UNIT_ASSERT(!s);
UNIT_ASSERT(s.count(42) == 0);
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(count == 1);
}
- Y_UNIT_TEST(TestSet2) {
+ Y_UNIT_TEST(TestSet2) {
using int_set = TSet<int, TLess<int>>;
int_set s;
std::pair<int_set::iterator, bool> p = s.insert(42);
@@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(distance(s3.begin(), s3.end()) == 5);
}
- Y_UNIT_TEST(TestErase) {
+ Y_UNIT_TEST(TestErase) {
TSet<int, TLess<int>> s;
s.insert(1);
s.erase(s.begin());
@@ -55,13 +55,13 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(nb == 0);
}
- Y_UNIT_TEST(TestInsert) {
+ Y_UNIT_TEST(TestInsert) {
TSet<int> s;
TSet<int>::iterator i = s.insert(s.end(), 0);
UNIT_ASSERT(*i == 0);
}
- Y_UNIT_TEST(TestFind) {
+ Y_UNIT_TEST(TestFind) {
TSet<int> s;
UNIT_ASSERT(s.find(0) == s.end());
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(crs.find(0) == crs.end());
}
- Y_UNIT_TEST(TestHas) {
+ Y_UNIT_TEST(TestHas) {
TSet<int> s;
UNIT_ASSERT(!s.contains(0));
@@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(s.contains(100));
}
- Y_UNIT_TEST(TestBounds) {
+ Y_UNIT_TEST(TestBounds) {
int array1[] = {1, 3, 6, 7};
TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0]));
TSet<int> const& crs = s;
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(*pcit.second == 7);
}
- Y_UNIT_TEST(TestImplementationCheck) {
+ Y_UNIT_TEST(TestImplementationCheck) {
TSet<int> tree;
tree.insert(1);
TSet<int>::iterator it = tree.begin();
@@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(int_cref == 1);
}
- Y_UNIT_TEST(TestReverseIteratorTest) {
+ Y_UNIT_TEST(TestReverseIteratorTest) {
TSet<int> tree;
tree.insert(1);
tree.insert(2);
@@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
}
- Y_UNIT_TEST(TestConstructorsAndAssignments) {
+ Y_UNIT_TEST(TestConstructorsAndAssignments) {
{
using container = TSet<int>;
@@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
using is_transparent = void;
};
- Y_UNIT_TEST(TestTemplateMethods) {
+ Y_UNIT_TEST(TestTemplateMethods) {
{
using KeySet = TSet<TKey, TKeyCmp>;
KeySet keySet;
diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp
index eb5a0662f8..cfe51e5e44 100644
--- a/util/generic/singleton.cpp
+++ b/util/generic/singleton.cpp
@@ -29,8 +29,8 @@ namespace {
void NPrivate::FillWithTrash(void* ptr, size_t len) {
#if defined(NDEBUG)
- Y_UNUSED(ptr);
- Y_UNUSED(len);
+ Y_UNUSED(ptr);
+ Y_UNUSED(len);
#else
if constexpr (NSan::TSanIsOn()) {
Y_UNUSED(ptr);
@@ -44,7 +44,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) {
void NPrivate::LockRecursive(TAtomic& lock) noexcept {
const TAtomicBase id = MyThreadId();
- Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization");
+ Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization");
if (!MyAtomicTryLock(lock, id)) {
TSpinWait sw;
@@ -56,6 +56,6 @@ void NPrivate::LockRecursive(TAtomic& lock) noexcept {
}
void NPrivate::UnlockRecursive(TAtomic& lock) noexcept {
- Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!");
+ Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!");
AtomicUnlock(&lock);
}
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index f5fa047f5c..38ee989c85 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -8,7 +8,7 @@
template <class T>
struct TSingletonTraits {
- static constexpr size_t Priority = 65536;
+ static constexpr size_t Priority = 65536;
};
namespace NPrivate {
diff --git a/util/generic/singleton_ut.cpp b/util/generic/singleton_ut.cpp
index 35ba90cd76..45a9852da3 100644
--- a/util/generic/singleton_ut.cpp
+++ b/util/generic/singleton_ut.cpp
@@ -2,13 +2,13 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestSingleton) {
+Y_UNIT_TEST_SUITE(TestSingleton) {
struct THuge {
char Buf[1000000];
int V = 1234;
};
- Y_UNIT_TEST(TestHuge) {
+ Y_UNIT_TEST(TestHuge) {
UNIT_ASSERT_VALUES_EQUAL(*HugeSingleton<int>(), 0);
UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<THuge>()->V, 1234);
}
@@ -24,13 +24,13 @@ Y_UNIT_TEST_SUITE(TestSingleton) {
TString Data2;
};
- Y_UNIT_TEST(TestConstructorParamsOrder) {
+ Y_UNIT_TEST(TestConstructorParamsOrder) {
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "123123")->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(20, "123123")->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "456456")->Data2, "123123");
}
- Y_UNIT_TEST(TestInstantiationWithConstructorParams) {
+ Y_UNIT_TEST(TestInstantiationWithConstructorParams) {
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10)->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<TWithParams>(20, "123123")->Data2, "123123");
{
diff --git a/util/generic/stack_ut.cpp b/util/generic/stack_ut.cpp
index 248127d326..b63e23711e 100644
--- a/util/generic/stack_ut.cpp
+++ b/util/generic/stack_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TYStackTest) {
- Y_UNIT_TEST(ExplicitBool) {
+Y_UNIT_TEST_SUITE(TYStackTest) {
+ Y_UNIT_TEST(ExplicitBool) {
TStack<int> s;
UNIT_ASSERT(!s);
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index ab39fc7537..862a427077 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -46,7 +46,7 @@ public:
using size_type = size_t;
using difference_type = ptrdiff_t;
- static constexpr size_t npos = size_t(-1);
+ static constexpr size_t npos = size_t(-1);
using const_iterator = const TCharType*;
using const_reference = const TCharType&;
@@ -144,13 +144,13 @@ public:
}
inline const_iterator cbegin() const noexcept {
- return begin();
- }
-
+ return begin();
+ }
+
inline const_iterator cend() const noexcept {
- return end();
- }
-
+ return end();
+ }
+
inline const_reverse_iterator rbegin() const noexcept {
return const_reverse_iterator(Ptr() + size());
}
@@ -294,35 +294,35 @@ public:
return equal(LegacySubString(*this, p, n), LegacySubString(t, 0, n1));
}
- static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
+ static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen);
}
- static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
+ static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen);
}
- inline bool StartsWith(const TCharType* s, size_t n) const noexcept {
- return StartsWith(Ptr(), Len(), s, n);
+ inline bool StartsWith(const TCharType* s, size_t n) const noexcept {
+ return StartsWith(Ptr(), Len(), s, n);
}
inline bool StartsWith(const TStringView s) const noexcept {
return StartsWith(s.data(), s.length());
}
- inline bool StartsWith(TCharType ch) const noexcept {
+ inline bool StartsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(*Ptr(), ch);
}
- inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
- return EndsWith(Ptr(), Len(), s, n);
+ inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
+ return EndsWith(Ptr(), Len(), s, n);
}
inline bool EndsWith(const TStringView s) const noexcept {
return EndsWith(s.data(), s.length());
}
- inline bool EndsWith(TCharType ch) const noexcept {
+ inline bool EndsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(Ptr()[Len() - 1], ch);
}
@@ -432,7 +432,7 @@ public:
// ~~ Read access ~~
inline TCharType at(size_t pos) const noexcept {
- if (Y_LIKELY(pos < Len())) {
+ if (Y_LIKELY(pos < Len())) {
return (Ptr())[pos];
}
return 0;
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 70b9360d58..3c046ea8a3 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -153,9 +153,9 @@ public:
inline TBasicStringBuf(const TBasicStringBuf& src, size_t pos) noexcept
: TBasicStringBuf(src, pos, TBase::npos)
- {
- }
-
+ {
+ }
+
Y_PURE_FUNCTION inline TBasicStringBuf SubString(size_t pos, size_t n) const noexcept {
pos = Min(pos, size());
n = Min(n, size() - pos);
@@ -290,7 +290,7 @@ public:
SplitOn(pos, l, r, 0);
}
- /*
+ /*
// Not implemented intentionally, use TrySplitOn() instead
void RSplitOn(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
void RSplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
@@ -319,7 +319,7 @@ public:
public:
inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept {
- if (this->StartsWith(prefix)) {
+ if (this->StartsWith(prefix)) {
result = Tail(prefix.size());
return true;
}
@@ -327,7 +327,7 @@ public:
}
inline bool BeforeSuffix(const TdSelf& suffix, TdSelf& result) const noexcept {
- if (this->EndsWith(suffix)) {
+ if (this->EndsWith(suffix)) {
result = Head(size() - suffix.size());
return true;
}
@@ -370,7 +370,7 @@ public:
SplitOn(pos, tok, *this);
return tok;
}
- /*
+ /*
// See comment on RSplitOn() above
TdSelf RSplitOffOn(size_t pos);
TdSelf RNextTokOn(size_t pos);
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 69cde785af..106bb097d5 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -4,7 +4,7 @@
#include <string_view>
-Y_UNIT_TEST_SUITE(TStrBufTest) {
+Y_UNIT_TEST_SUITE(TStrBufTest) {
Y_UNIT_TEST(TestConstructorsAndOperators) {
TStringBuf str("qwerty");
@@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(helloWorld.size(), fromStringBuf.size());
}
- Y_UNIT_TEST(TestConstExpr) {
+ Y_UNIT_TEST(TestConstExpr) {
static constexpr TStringBuf str1("qwe\0rty", 7);
static constexpr TStringBuf str2(str1.data(), str1.size());
static constexpr TStringBuf str3 = "qwe\0rty"sv;
@@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
static_assert(str1.size() == str4.size());
}
- Y_UNIT_TEST(TestAfter) {
+ Y_UNIT_TEST(TestAfter) {
TStringBuf str("qwerty");
UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty"));
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_STRINGS_EQUAL(empty.After('x'), empty);
}
- Y_UNIT_TEST(TestBefore) {
+ Y_UNIT_TEST(TestBefore) {
TStringBuf str("qwerty");
UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q"));
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_VALUES_EQUAL(str.Before('q'), TStringBuf());
}
- Y_UNIT_TEST(TestRAfterBefore) {
+ Y_UNIT_TEST(TestRAfterBefore) {
TStringBuf str("a/b/c");
UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('/'), "c");
UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('_'), str);
@@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_STRINGS_EQUAL(str.RBefore('a'), "");
}
- Y_UNIT_TEST(TestAfterPrefix) {
+ Y_UNIT_TEST(TestAfterPrefix) {
TStringBuf str("cat_dog");
TStringBuf r = "the_same";
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!a.SkipPrefix("def") && a == "");
}
- Y_UNIT_TEST(TestBeforeSuffix) {
+ Y_UNIT_TEST(TestBeforeSuffix) {
TStringBuf str("cat_dog");
TStringBuf r = "the_same";
@@ -135,12 +135,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!a.ChopSuffix("abc") && a == "");
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
UNIT_ASSERT(TStringBuf().empty());
UNIT_ASSERT(!TStringBuf("q").empty());
}
- Y_UNIT_TEST(TestShift) {
+ Y_UNIT_TEST(TestShift) {
TStringBuf qw("qwerty");
TStringBuf str;
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(str, TStringBuf("rt"));
}
- Y_UNIT_TEST(TestSplit) {
+ Y_UNIT_TEST(TestSplit) {
TStringBuf qw("qwerty");
TStringBuf lt, rt;
@@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(ty, TStringBuf("ty"));
}
- Y_UNIT_TEST(TestNextTok) {
+ Y_UNIT_TEST(TestNextTok) {
TStringBuf buf("12q45q");
TStringBuf tok;
@@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf.NextTok('q', tok));
}
- Y_UNIT_TEST(TestNextStringTok) {
+ Y_UNIT_TEST(TestNextStringTok) {
TStringBuf buf1("a@@b@@c");
UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a"));
UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b"));
@@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf3, TStringBuf());
}
- Y_UNIT_TEST(TestReadLine) {
+ Y_UNIT_TEST(TestReadLine) {
TStringBuf buf("12\n45\r\n\r\n23");
TStringBuf tok;
@@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf.ReadLine(tok));
}
- Y_UNIT_TEST(TestRFind) {
+ Y_UNIT_TEST(TestRFind) {
TStringBuf buf1 = "123123456";
UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5);
UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6);
@@ -240,7 +240,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf4.rfind('3'), 2);
}
- Y_UNIT_TEST(TestRNextTok) {
+ Y_UNIT_TEST(TestRNextTok) {
TStringBuf buf1("a.b.c");
UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c"));
UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b"));
@@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == ""); // not modified
}
- Y_UNIT_TEST(TestRSplitOff) {
+ Y_UNIT_TEST(TestRSplitOff) {
TStringBuf buf1("a.b.c");
UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b"));
UNIT_ASSERT_EQUAL(buf1, TStringBuf("c"));
@@ -265,18 +265,18 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf2.RSplitOff('.'), TStringBuf());
UNIT_ASSERT_EQUAL(buf2, TStringBuf("a"));
}
-
- Y_UNIT_TEST(TestCBeginCEnd) {
- const char helloThere[] = "Hello there";
- TStringBuf s{helloThere};
-
- size_t index = 0;
- for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
- }
- }
-
- Y_UNIT_TEST(TestSplitOnAt) {
+
+ Y_UNIT_TEST(TestCBeginCEnd) {
+ const char helloThere[] = "Hello there";
+ TStringBuf s{helloThere};
+
+ size_t index = 0;
+ for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
+ }
+ }
+
+ Y_UNIT_TEST(TestSplitOnAt) {
TStringBuf s = "abcabc";
TStringBuf l, r;
@@ -296,28 +296,28 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
// out of range
pos = 100500;
- UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true
+ UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true
UNIT_ASSERT(l == "abcabc" && r == "");
- l = "111";
- r = "222";
- UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true
+ l = "111";
+ r = "222";
+ UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true
UNIT_ASSERT(l == "abcabc" && r == "");
// npos
pos = s.find("missing");
- l = "111";
- r = "222";
+ l = "111";
+ r = "222";
UNIT_ASSERT(!s.TrySplitOn(pos, l, r));
- UNIT_ASSERT(l == "111" && r == "222"); // not modified
+ UNIT_ASSERT(l == "111" && r == "222"); // not modified
s.SplitOn(pos, l, r);
- UNIT_ASSERT(l == "abcabc" && r == ""); // modified
+ UNIT_ASSERT(l == "abcabc" && r == ""); // modified
- l = "111";
- r = "222";
+ l = "111";
+ r = "222";
UNIT_ASSERT(!s.TrySplitAt(pos, l, r));
- UNIT_ASSERT(l == "111" && r == "222"); // not modified
+ UNIT_ASSERT(l == "111" && r == "222"); // not modified
s.SplitAt(pos, l, r);
- UNIT_ASSERT(l == "abcabc" && r == ""); // modified
+ UNIT_ASSERT(l == "abcabc" && r == ""); // modified
}
template <class T>
@@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(TStringBuf(val).size() == 5);
}
- Y_UNIT_TEST(TestPassingArraysByConstReference) {
+ Y_UNIT_TEST(TestPassingArraysByConstReference) {
char data[] = "Hello\0word";
PassByConstReference(data);
}
diff --git a/util/generic/string.h b/util/generic/string.h
index 8cd8aa6917..fc2109198a 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -1067,7 +1067,7 @@ public:
}
TBasicString& pop_back() Y_NOEXCEPT {
- Y_ASSERT(!this->empty());
+ Y_ASSERT(!this->empty());
MutRef().pop_back();
diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp
index b87fa2843e..00c9f3bafa 100644
--- a/util/generic/string_transparent_hash_ut.cpp
+++ b/util/generic/string_transparent_hash_ut.cpp
@@ -1,19 +1,19 @@
#include "string.h"
#include "vector.h"
-#include "strbuf.h"
+#include "strbuf.h"
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
-#include <util/str_stl.h>
+#include <util/str_stl.h>
-Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
- Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
- // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
- // we stuck with C++17 right now).
- absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
- // If either `THash` or `TEqualTo` is not transparent compilation will fail.
- UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
- UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
+Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
+ Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
+ // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
+ // we stuck with C++17 right now).
+ absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
+ // If either `THash` or `TEqualTo` is not transparent compilation will fail.
+ UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
+ UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
}
}
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index ac82e9091d..f96bec6480 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -5,7 +5,7 @@
#include "yexception.h"
#include <util/charset/wide.h>
-#include <util/str_stl.h>
+#include <util/str_stl.h>
#include <util/stream/output.h>
#include <util/string/subst.h>
@@ -30,8 +30,8 @@ public:
const char data[] = "abc\0def\0";
TString s(data, sizeof(data));
UNIT_ASSERT(s.size() == sizeof(data));
- UNIT_ASSERT(s.StartsWith(s));
- UNIT_ASSERT(s.EndsWith(s));
+ UNIT_ASSERT(s.StartsWith(s));
+ UNIT_ASSERT(s.EndsWith(s));
UNIT_ASSERT(s.Contains('\0'));
const char raw_def[] = "def";
@@ -54,7 +54,7 @@ public:
UNIT_ASSERT(s == copy);
TString prefix(data, 5);
- UNIT_ASSERT(s.StartsWith(prefix));
+ UNIT_ASSERT(s.StartsWith(prefix));
UNIT_ASSERT(s != prefix);
UNIT_ASSERT(s > prefix);
UNIT_ASSERT(s > s.data());
@@ -269,7 +269,7 @@ protected:
TStringType xx;
// ISO-IEC-14882:1998(E), 21.3.6, paragraph 3
- UNIT_ASSERT(xx.data() != nullptr);
+ UNIT_ASSERT(xx.data() != nullptr);
}
void c_str() {
@@ -537,15 +537,15 @@ protected:
}
}
- void cbegin_cend() {
- const char helloThere[] = "Hello there";
+ void cbegin_cend() {
+ const char helloThere[] = "Hello there";
TString s = helloThere;
- size_t index = 0;
- for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
- }
- }
-
+ size_t index = 0;
+ for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
+ }
+ }
+
void compare() {
TStringType str1(Data_.abcdef());
TStringType str2;
@@ -1128,7 +1128,7 @@ public:
UNIT_TEST(capacity);
UNIT_TEST(assign);
UNIT_TEST(copy);
- UNIT_TEST(cbegin_cend);
+ UNIT_TEST(cbegin_cend);
UNIT_TEST(compare);
UNIT_TEST(find_last_of);
#if 0
@@ -1164,7 +1164,7 @@ public:
UNIT_TEST(capacity);
UNIT_TEST(assign);
UNIT_TEST(copy);
- UNIT_TEST(cbegin_cend);
+ UNIT_TEST(cbegin_cend);
UNIT_TEST(compare);
UNIT_TEST(find_last_of);
#if 0
@@ -1190,19 +1190,19 @@ Y_UNIT_TEST_SUITE(TStringConversionTest) {
UNIT_ASSERT_VALUES_EQUAL(stdAbra, "cadabra");
}
}
-
-Y_UNIT_TEST_SUITE(HashFunctorTests) {
- Y_UNIT_TEST(TestTransparency) {
- THash<TString> h;
- const char* ptr = "a";
- const TStringBuf strbuf = ptr;
- const TString str = ptr;
- const std::string stdStr = ptr;
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf));
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str));
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr));
- }
-}
+
+Y_UNIT_TEST_SUITE(HashFunctorTests) {
+ Y_UNIT_TEST(TestTransparency) {
+ THash<TString> h;
+ const char* ptr = "a";
+ const TStringBuf strbuf = ptr;
+ const TString str = ptr;
+ const std::string stdStr = ptr;
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf));
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str));
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr));
+ }
+}
#if !defined(TSTRING_IS_STD_STRING)
Y_UNIT_TEST_SUITE(StdNonConformant) {
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 44bb10bdeb..cd9db7876b 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -981,21 +981,21 @@ public:
void TestPrefixSuffix() {
const TStringType emptyStr;
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false);
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0};
const TStringType str(chars);
- UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
- UNIT_ASSERT_EQUAL(str.StartsWith('o'), false);
- UNIT_ASSERT_EQUAL(str.EndsWith('o'), true);
- UNIT_ASSERT_EQUAL(str.EndsWith('h'), false);
- UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
- UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
+ UNIT_ASSERT_EQUAL(str.StartsWith('o'), false);
+ UNIT_ASSERT_EQUAL(str.EndsWith('o'), true);
+ UNIT_ASSERT_EQUAL(str.EndsWith('h'), false);
+ UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
}
#ifndef TSTRING_IS_STD_STRING
diff --git a/util/generic/typelist.h b/util/generic/typelist.h
index 5ce26ab97c..90d7e4239e 100644
--- a/util/generic/typelist.h
+++ b/util/generic/typelist.h
@@ -1,7 +1,7 @@
#pragma once
-#include <util/system/types.h>
-
+#include <util/system/types.h>
+
#include <util/generic/typetraits.h>
#include <type_traits>
@@ -109,6 +109,6 @@ using TFixedWidthSignedInt = typename TFixedWidthSignedInts::template TSelectBy<
template <typename T>
using TFixedWidthUnsignedInt = typename TFixedWidthUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
-
-template <typename T>
-using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+
+template <typename T>
+using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp
index eeabfa97b1..e2872feab7 100644
--- a/util/generic/typelist_ut.cpp
+++ b/util/generic/typelist_ut.cpp
@@ -10,7 +10,7 @@ class TTypeListTest: public TTestBase {
UNIT_TEST(TestSimple);
UNIT_TEST(TestHave);
UNIT_TEST(TestGet);
- UNIT_TEST(TestFloatList);
+ UNIT_TEST(TestFloatList);
UNIT_TEST(TestSelectBy);
UNIT_TEST_SUITE_END();
@@ -73,13 +73,13 @@ public:
using TMyMapPTATB = TMyMap<TA*, TB>;
UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIsNArgTemplate>::type, TMyMapPTATB);
}
-
- void TestFloatList() {
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double);
- }
+
+ void TestFloatList() {
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double);
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TTypeListTest);
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index d165bd1a06..57d07c62ff 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -1,6 +1,6 @@
#pragma once
-#include "va_args.h"
+#include "va_args.h"
#include <util/system/defaults.h>
@@ -115,7 +115,7 @@ public:
/*
* can be used in function templates for effective parameters passing
*/
- using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>;
+ using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>;
};
template <>
@@ -162,79 +162,79 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
struct THas##name \
: TBaseHas##name<T, std::is_class<T>::value || std::is_union<T>::value> {}
-#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name)
+#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name)
-/* @def Y_HAS_MEMBER
- *
- * This macro should be used to define compile-time introspection helper classes for template
- * metaprogramming.
- *
- * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)`
+/* @def Y_HAS_MEMBER
+ *
+ * This macro should be used to define compile-time introspection helper classes for template
+ * metaprogramming.
+ *
+ * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)`
* will define class `THasABC` with static member `value` of type bool. Usage with one parameter
- * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`.
- *
- * @code
- * #include <type_traits>
- *
- * Y_HAS_MEMBER(push_front, PushFront);
- *
- * template <typename T, typename U>
+ * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`.
+ *
+ * @code
+ * #include <type_traits>
+ *
+ * Y_HAS_MEMBER(push_front, PushFront);
+ *
+ * template <typename T, typename U>
* std::enable_if_t<THasPushFront<T>::value, void>
- * PushFront(T& container, const U value) {
- * container.push_front(x);
- * }
- *
- * template <typename T, typename U>
+ * PushFront(T& container, const U value) {
+ * container.push_front(x);
+ * }
+ *
+ * template <typename T, typename U>
* std::enable_if_t<!THasPushFront<T>::value, void>
- * PushFront(T& container, const U value) {
- * container.insert(container.begin(), x);
- * }
- * @endcode
- */
-#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__))
-
+ * PushFront(T& container, const U value) {
+ * container.insert(container.begin(), x);
+ * }
+ * @endcode
+ */
+#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__))
+
#define Y_HAS_SUBTYPE_IMPL_2(subtype, name) \
template <class T, class = void> \
struct THas##name: std::false_type {}; \
template <class T> \
struct THas##name<T, ::TVoidT<typename T::subtype>>: std::true_type {};
-#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name)
+#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name)
-/* @def Y_HAS_SUBTYPE
- *
- * This macro should be used to define compile-time introspection helper classes for template
- * metaprogramming.
- *
- * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)`
+/* @def Y_HAS_SUBTYPE
+ *
+ * This macro should be used to define compile-time introspection helper classes for template
+ * metaprogramming.
+ *
+ * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)`
* will define class `THasABC` with static member `value` of type bool. Usage with one parameter
- * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`.
- *
- * @code
- * Y_HAS_MEMBER(find, FindMethod);
- * Y_HAS_SUBTYPE(const_iterator, ConstIterator);
- * Y_HAS_SUBTYPE(key_type, KeyType);
- *
- * template <typename T>
- * using TIsAssocCont = std::conditional_t<
+ * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`.
+ *
+ * @code
+ * Y_HAS_MEMBER(find, FindMethod);
+ * Y_HAS_SUBTYPE(const_iterator, ConstIterator);
+ * Y_HAS_SUBTYPE(key_type, KeyType);
+ *
+ * template <typename T>
+ * using TIsAssocCont = std::conditional_t<
* THasFindMethod<T>::value && THasConstIterator<T>::value && THasKeyType<T>::value,
- * std::true_type,
- * std::false_type,
- * >;
- *
+ * std::true_type,
+ * std::false_type,
+ * >;
+ *
* static_assert(TIsAssocCont<TVector<int>>::value == false, "");
* static_assert(TIsAssocCont<THashMap<int>>::value == true, "");
- * @endcode
- */
-#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__))
-
+ * @endcode
+ */
+#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__))
+
template <class T1, class T2>
struct TPodTraits<std::pair<T1, T2>> {
enum {
IsPod = TTypeTraits<T1>::IsPod && TTypeTraits<T2>::IsPod
};
};
-
+
template <class T>
struct TIsPointerToConstMemberFunction: std::false_type {
};
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index e7571c75ec..496e357dd7 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -78,13 +78,13 @@ namespace {
UNIT_ASSERT_C(x_, #x " != " #y); \
}
-Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
- Y_UNIT_TEST(TestIsSame) {
+Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
+ Y_UNIT_TEST(TestIsSame) {
UNIT_ASSERT((std::is_same<int, int>::value));
UNIT_ASSERT(!(std::is_same<signed int, unsigned int>::value));
}
- Y_UNIT_TEST(TestRemoveReference) {
+ Y_UNIT_TEST(TestRemoveReference) {
ASSERT_SAME_TYPE(std::remove_reference_t<int>, int);
ASSERT_SAME_TYPE(std::remove_reference_t<const int>, const int);
ASSERT_SAME_TYPE(std::remove_reference_t<int&>, int);
@@ -96,23 +96,23 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
ASSERT_SAME_TYPE(std::remove_reference_t<TIncompleteType&>, TIncompleteType);
}
- Y_UNIT_TEST(TestRemoveConst) {
+ Y_UNIT_TEST(TestRemoveConst) {
ASSERT_SAME_TYPE(std::remove_const_t<const int>, int);
}
- Y_UNIT_TEST(TestRemoveVolatile) {
+ Y_UNIT_TEST(TestRemoveVolatile) {
ASSERT_SAME_TYPE(std::remove_volatile_t<volatile int>, int);
}
- Y_UNIT_TEST(TestRemoveCV) {
+ Y_UNIT_TEST(TestRemoveCV) {
ASSERT_SAME_TYPE(std::remove_cv_t<const volatile int>, int);
}
- Y_UNIT_TEST(TestAddCV) {
+ Y_UNIT_TEST(TestAddCV) {
ASSERT_SAME_TYPE(std::add_cv_t<int>, const volatile int);
}
- Y_UNIT_TEST(TestClass) {
+ Y_UNIT_TEST(TestClass) {
UNIT_ASSERT(std::is_class<TString>::value);
UNIT_ASSERT(!std::is_class<ETestEnum>::value);
UNIT_ASSERT(!std::is_class<int>::value);
@@ -168,35 +168,35 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
UNIT_ASSERT(!std::is_signed<ETypedEnum>::value);
}
- Y_UNIT_TEST(TestBool) {
+ Y_UNIT_TEST(TestBool) {
TestArithmeticType<bool>();
TestUnsignedIntType<bool>();
}
- Y_UNIT_TEST(TestUnsignedChar) {
+ Y_UNIT_TEST(TestUnsignedChar) {
TestArithmeticType<unsigned char>();
TestUnsignedIntType<unsigned char>();
}
- Y_UNIT_TEST(TestSizeT) {
+ Y_UNIT_TEST(TestSizeT) {
TestArithmeticType<size_t>();
TestUnsignedIntType<size_t>();
}
- Y_UNIT_TEST(TestInt) {
+ Y_UNIT_TEST(TestInt) {
TestArithmeticType<int>();
TestSignedIntType<int>();
}
- Y_UNIT_TEST(TestDouble) {
+ Y_UNIT_TEST(TestDouble) {
TestArithmeticType<double>();
}
- Y_UNIT_TEST(TestLongDouble) {
+ Y_UNIT_TEST(TestLongDouble) {
TestArithmeticType<long double>();
}
- Y_UNIT_TEST(TestAddRValueReference) {
+ Y_UNIT_TEST(TestAddRValueReference) {
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int>, int&&);
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int const&>, int const&);
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*>, int*&&);
@@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<void>, void);
}
- Y_UNIT_TEST(TestIsEmpty) {
+ Y_UNIT_TEST(TestIsEmpty) {
UNIT_ASSERT(std::is_empty<TEmptyClass>::value);
UNIT_ASSERT(std::is_empty<TEmptyDerivedClass>::value);
UNIT_ASSERT(std::is_empty<TAnotherEmptyClass>::value);
@@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
UNIT_ASSERT(!std::is_empty<TNonEmptyDerivedClass>::value);
}
- Y_UNIT_TEST(TestIsStandardLayout) {
+ Y_UNIT_TEST(TestIsStandardLayout) {
UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass1>::value);
UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass2>::value);
UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass1>::value);
@@ -230,10 +230,10 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
template <class T>
using TTrySum = decltype(std::declval<T>() + std::declval<T>());
- Y_UNIT_TEST(TestIsTriviallyCopyable) {
- struct TPod {
- int value;
- };
+ Y_UNIT_TEST(TestIsTriviallyCopyable) {
+ struct TPod {
+ int value;
+ };
struct TNontriviallyCopyAssignable {
TNontriviallyCopyAssignable(const TNontriviallyCopyAssignable&) = default;
@@ -381,7 +381,7 @@ namespace {
#define UNIT_ASSERT_EQUAL_ENUM(expected, actual) UNIT_ASSERT_VALUES_EQUAL((bool)(expected), (bool)(actual))
-Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) {
+Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) {
template <typename T>
void TestImpl() {
//UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPod, TTypeTraits<T>::IsPod);
@@ -434,22 +434,22 @@ enum class E8: ui8 {
X
};
-// test for std::underlying_type_t
-static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), "");
-static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), "");
-static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), "");
-
-// tests for TFixedWidthUnsignedInt
-static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, "");
-static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, "");
-static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, "");
-static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, "");
-
-// tests for TFixedWidthSignedInt
-static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, "");
-static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, "");
-static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, "");
-static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, "");
+// test for std::underlying_type_t
+static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), "");
+static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), "");
+static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), "");
+
+// tests for TFixedWidthUnsignedInt
+static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, "");
+static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, "");
+static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, "");
+static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, "");
+
+// tests for TFixedWidthSignedInt
+static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, "");
+static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, "");
+static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, "");
+static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, "");
// test for TIsSpecializationOf
static_assert(TIsSpecializationOf<std::vector, std::vector<int>>::value, "");
diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make
index 6eaf24cc5f..fbe31ffc32 100644
--- a/util/generic/ut/ya.make
+++ b/util/generic/ut/ya.make
@@ -58,16 +58,16 @@ SRCS(
INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc)
-IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
- # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
- # (somewhere in unscaledcycleclock.cc).
- PEERDIR(
+IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
+ # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
+ # (somewhere in unscaledcycleclock.cc).
+ PEERDIR(
library/cpp/containers/absl_flat_hash
- )
-
- SRCS(
- generic/string_transparent_hash_ut.cpp
- )
-ENDIF()
-
+ )
+
+ SRCS(
+ generic/string_transparent_hash_ut.cpp
+ )
+ENDIF()
+
END()
diff --git a/util/generic/utility.h b/util/generic/utility.h
index 43b98eeafc..0deda97bb7 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -66,8 +66,8 @@ static inline void SecureZero(T& t) noexcept {
}
namespace NSwapCheck {
- Y_HAS_MEMBER(swap);
- Y_HAS_MEMBER(Swap);
+ Y_HAS_MEMBER(swap);
+ Y_HAS_MEMBER(Swap);
template <class T, class = void>
struct TSwapSelector {
diff --git a/util/generic/va_args.cpp b/util/generic/va_args.cpp
index 2266d05a0d..6b66aec5a4 100644
--- a/util/generic/va_args.cpp
+++ b/util/generic/va_args.cpp
@@ -2,14 +2,14 @@
// Test that it compiles
#define __DUMMY__(x)
-Y_MAP_ARGS(__DUMMY__, 1, 2, 3);
+Y_MAP_ARGS(__DUMMY__, 1, 2, 3);
#define __DUMMY_LAST__(x)
-Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3);
+Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3);
#undef __DUMMY_LAST__
#undef __DUMMY__
#define __MULTI_DUMMY__(x, y)
#define __MULTI_DUMMY_PROXY__(x) __MULTI_DUMMY__ x
-Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4));
+Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4));
#undef __MULTI_DUMMY_PROXY__
#undef __MULTI_DUMMY__
diff --git a/util/generic/va_args.h b/util/generic/va_args.h
index 33498d47ed..90eb5c17ad 100644
--- a/util/generic/va_args.h
+++ b/util/generic/va_args.h
@@ -16,7 +16,7 @@
* Used merely for working around an MSVC++ bug.
* See http://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
*/
-#define Y_PASS_VA_ARGS(x) x
+#define Y_PASS_VA_ARGS(x) x
/**
* Count number of arguments in `__VA_ARGS__`.
@@ -768,16 +768,16 @@
/**
* Macros for implementing overload by number of arguments.
- *
+ *
* Example usage:
- *
+ *
* @code{cpp}
* #define I1(arg1) Cout << Y_STRINGIZE(arg1) << Endl;
* #define I2(arg1, arg2) Cout << Y_STRINGIZE(arg1) << ';' << Y_STRINGIZE(arg2) << Endl;
- *
+ *
* #define Y_PRINT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, I2, I1)(__VA_ARGS__))
- * @endcode
- */
+ * @endcode
+ */
/// @{
#define Y_MACRO_IMPL_DISPATCHER_2(_0, _1, IMPL, ...) IMPL
#define Y_MACRO_IMPL_DISPATCHER_3(_0, _1, _2, IMPL, ...) IMPL
diff --git a/util/generic/va_args_gen.py b/util/generic/va_args_gen.py
index 232b53fca6..2dc5346f56 100755
--- a/util/generic/va_args_gen.py
+++ b/util/generic/va_args_gen.py
@@ -65,7 +65,7 @@ def count(limit):
print('#define Y_COUNT_ARGS(...) Y_PASS_VA_ARGS('
'__Y_COUNT_ARGS(__VA_ARGS__, {}))'.format(numbers))
print('#define __Y_COUNT_ARGS({}, N, ...) N'.format(u_numbers))
-
+
def get_elem(limit):
print(textwrap.dedent('''
diff --git a/util/generic/va_args_ut.cpp b/util/generic/va_args_ut.cpp
index a9c96a0f55..b07109095c 100644
--- a/util/generic/va_args_ut.cpp
+++ b/util/generic/va_args_ut.cpp
@@ -2,16 +2,16 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TMacroVarargMapTest) {
- Y_UNIT_TEST(TestMapArgs) {
- static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3);
+Y_UNIT_TEST_SUITE(TMacroVarargMapTest) {
+ Y_UNIT_TEST(TestMapArgs) {
+ static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3);
UNIT_ASSERT_STRINGS_EQUAL(COMBINED, "123");
}
- Y_UNIT_TEST(TestMapArgsWithLast) {
+ Y_UNIT_TEST(TestMapArgsWithLast) {
#define ADD(x) x +
#define ID(x) x
- static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5);
+ static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5);
UNIT_ASSERT_VALUES_EQUAL(SUM, 1 + 2 + 3 + 4 + 5);
#undef ADD
#undef ID
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 0f6b4037a0..19475a78ef 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -566,7 +566,7 @@ private:
void CheckInitializeList(const TVector<int>& v) {
for (size_t i = 0; i < v.size(); ++i) {
- UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i));
+ UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i));
}
}
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 5fc8c82912..6d1b86eb44 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -24,7 +24,7 @@ namespace NPrivate {
using TDiff = decltype(T() - T());
public:
- constexpr TSimpleXRange(T start, T finish) noexcept
+ constexpr TSimpleXRange(T start, T finish) noexcept
: Start(start)
, Finish(Max(start, finish))
{
@@ -38,20 +38,20 @@ namespace NPrivate {
using reference = const T&;
using iterator_category = std::random_access_iterator_tag;
- constexpr TIterator(T value) noexcept
+ constexpr TIterator(T value) noexcept
: Value(value)
{
}
- constexpr T operator*() const noexcept {
+ constexpr T operator*() const noexcept {
return Value;
}
- constexpr bool operator!=(const TIterator& other) const noexcept {
+ constexpr bool operator!=(const TIterator& other) const noexcept {
return Value != other.Value;
}
- constexpr bool operator==(const TIterator& other) const noexcept {
+ constexpr bool operator==(const TIterator& other) const noexcept {
return Value == other.Value;
}
@@ -65,23 +65,23 @@ namespace NPrivate {
return *this;
}
- constexpr TDiff operator-(const TIterator& b) const noexcept {
+ constexpr TDiff operator-(const TIterator& b) const noexcept {
return Value - b.Value;
}
template <typename IntType>
- constexpr TIterator operator+(const IntType& b) const noexcept {
+ constexpr TIterator operator+(const IntType& b) const noexcept {
return TIterator(Value + b);
}
template <typename IntType>
- TIterator& operator+=(const IntType& b) noexcept {
+ TIterator& operator+=(const IntType& b) noexcept {
Value += b;
return *this;
}
template <typename IntType>
- constexpr TIterator operator-(const IntType& b) const noexcept {
+ constexpr TIterator operator-(const IntType& b) const noexcept {
return TIterator(Value - b);
}
@@ -103,15 +103,15 @@ namespace NPrivate {
using iterator = TIterator;
using const_iterator = TIterator;
- constexpr TIterator begin() const noexcept {
+ constexpr TIterator begin() const noexcept {
return TIterator(Start);
}
- constexpr TIterator end() const noexcept {
+ constexpr TIterator end() const noexcept {
return TIterator(Finish);
}
- constexpr T size() const noexcept {
+ constexpr T size() const noexcept {
return Finish - Start;
}
@@ -130,7 +130,7 @@ namespace NPrivate {
using TDiff = decltype(T() - T());
public:
- constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
+ constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
: Start_(start)
, Step_(step)
, Finish_(CalcRealFinish(Start_, finish, Step_))
@@ -146,21 +146,21 @@ namespace NPrivate {
using reference = const T&;
using iterator_category = std::random_access_iterator_tag;
- constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
+ constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
: Value_(value)
, Parent_(&parent)
{
}
- constexpr T operator*() const noexcept {
+ constexpr T operator*() const noexcept {
return Value_;
}
- constexpr bool operator!=(const TIterator& other) const noexcept {
+ constexpr bool operator!=(const TIterator& other) const noexcept {
return Value_ != other.Value_;
}
- constexpr bool operator==(const TIterator& other) const noexcept {
+ constexpr bool operator==(const TIterator& other) const noexcept {
return Value_ == other.Value_;
}
@@ -174,23 +174,23 @@ namespace NPrivate {
return *this;
}
- constexpr TDiff operator-(const TIterator& b) const noexcept {
+ constexpr TDiff operator-(const TIterator& b) const noexcept {
return (Value_ - b.Value_) / Parent_->Step_;
}
template <typename IntType>
- constexpr TIterator operator+(const IntType& b) const noexcept {
+ constexpr TIterator operator+(const IntType& b) const noexcept {
return TIterator(*this) += b;
}
template <typename IntType>
- TIterator& operator+=(const IntType& b) noexcept {
+ TIterator& operator+=(const IntType& b) noexcept {
Value_ += b * Parent_->Step_;
return *this;
}
template <typename IntType>
- constexpr TIterator operator-(const IntType& b) const noexcept {
+ constexpr TIterator operator-(const IntType& b) const noexcept {
return TIterator(*this) -= b;
}
@@ -209,16 +209,16 @@ namespace NPrivate {
using iterator = TIterator;
using const_iterator = TIterator;
- constexpr TIterator begin() const noexcept {
+ constexpr TIterator begin() const noexcept {
return TIterator(Start_, *this);
}
- constexpr TIterator end() const noexcept {
+ constexpr TIterator end() const noexcept {
return TIterator(Finish_, *this);
}
static T CalcRealFinish(T start, T expFinish, TDiff step) {
- Y_ASSERT(step != 0);
+ Y_ASSERT(step != 0);
if (step > 0) {
if (expFinish > start) {
return start + step * ((expFinish - 1 - start) / step + 1);
@@ -228,7 +228,7 @@ namespace NPrivate {
return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step);
}
- constexpr T size() const noexcept {
+ constexpr T size() const noexcept {
return (Finish_ - Start_) / Step_;
}
@@ -251,18 +251,18 @@ namespace NPrivate {
* @param step must be non-zero
*/
template <typename T>
-constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
+constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
return {start, finish, step};
}
/// generate sequence [start; finish)
template <typename T>
-constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {
+constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {
return {start, finish};
}
/// generate sequence [0; finish)
template <typename T>
-constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) {
+constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) {
return xrange(T(), finish);
}
diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp
index 8106da03e7..d0a43637cf 100644
--- a/util/generic/xrange_ut.cpp
+++ b/util/generic/xrange_ut.cpp
@@ -6,7 +6,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/string/builder.h>
-Y_UNIT_TEST_SUITE(XRange) {
+Y_UNIT_TEST_SUITE(XRange) {
void TestXRangeImpl(size_t begin, size_t end) {
size_t count = 0;
size_t sum = 0;
@@ -40,18 +40,18 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size());
}
- Y_UNIT_TEST(IncrementWorks) {
+ Y_UNIT_TEST(IncrementWorks) {
TestXRangeImpl(0, 10);
TestXRangeImpl(10, 20);
}
- Y_UNIT_TEST(DecrementWorks) {
+ Y_UNIT_TEST(DecrementWorks) {
TestSteppedXRangeImpl(10, 0, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1});
TestSteppedXRangeImpl(10, -1, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0});
TestSteppedXRangeImpl(20, 9, -1, {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10});
}
- Y_UNIT_TEST(StepWorks) {
+ Y_UNIT_TEST(StepWorks) {
TestSteppedXRangeImpl(0, 0, 1, {});
TestSteppedXRangeImpl(0, 9, 3, {0, 3, 6});
TestSteppedXRangeImpl(0, 10, 3, {0, 3, 6, 9});
@@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(XRange) {
TestSteppedXRangeImpl(15, -2, -4, {15, 11, 7, 3, -1});
}
- Y_UNIT_TEST(PointersWorks) {
+ Y_UNIT_TEST(PointersWorks) {
TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6};
const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0));
size_t digSumByIt = 0;
@@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected);
}
- Y_UNIT_TEST(SizeMethodCheck) {
+ Y_UNIT_TEST(SizeMethodCheck) {
UNIT_ASSERT_VALUES_EQUAL(xrange(5).size(), 5);
UNIT_ASSERT_VALUES_EQUAL(xrange(0, 5, 2).size(), 3);
UNIT_ASSERT_VALUES_EQUAL(xrange(0, 6, 2).size(), 3);
@@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
};
- Y_UNIT_TEST(ConvertionWorks) {
+ Y_UNIT_TEST(ConvertionWorks) {
TVector<size_t> data = {0, 1, 2, 3, 4, 5, 6, 7, 8};
TVector<size_t> convertionResults[] = {xrange<size_t>(9),
@@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(emptyRange.size(), 0);
for (auto i : emptyRange) {
- Y_UNUSED(i);
+ Y_UNUSED(i);
UNIT_ASSERT(false);
}
@@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
}
- Y_UNIT_TEST(EmptySimpleRange) {
+ Y_UNIT_TEST(EmptySimpleRange) {
using TSimpleRange = decltype(xrange(1));
const TSimpleRange emptySimpleRanges[] = {
@@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(XRange) {
TestEmptyRanges(emptySimpleRanges);
}
- Y_UNIT_TEST(EmptySteppedRange) {
+ Y_UNIT_TEST(EmptySteppedRange) {
using TSteppedRange = decltype(xrange(1, 10, 1));
const TSteppedRange emptySteppedRanges[] = {
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 2ce6c4369d..630aaa42e2 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -75,22 +75,22 @@ void TSystemError::Init() {
exc << TStringBuf(") ");
}
-NPrivateException::yexception::yexception() {
- ZeroTerminate();
-}
-
-TStringBuf NPrivateException::yexception::AsStrBuf() const {
- if (Buf_.Left()) {
- return TStringBuf(Buf_.Data(), Buf_.Filled());
- }
-
- return TStringBuf(Buf_.Data(), Buf_.Filled() - 1);
-}
-
-void NPrivateException::yexception::ZeroTerminate() noexcept {
- char* end = (char*)Buf_.Current();
-
- if (!Buf_.Left()) {
+NPrivateException::yexception::yexception() {
+ ZeroTerminate();
+}
+
+TStringBuf NPrivateException::yexception::AsStrBuf() const {
+ if (Buf_.Left()) {
+ return TStringBuf(Buf_.Data(), Buf_.Filled());
+ }
+
+ return TStringBuf(Buf_.Data(), Buf_.Filled() - 1);
+}
+
+void NPrivateException::yexception::ZeroTerminate() noexcept {
+ char* end = (char*)Buf_.Current();
+
+ if (!Buf_.Left()) {
--end;
}
@@ -98,11 +98,11 @@ void NPrivateException::yexception::ZeroTerminate() noexcept {
}
const char* NPrivateException::yexception::what() const noexcept {
- return Buf_.Data();
+ return Buf_.Data();
}
const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept {
- return nullptr;
+ return nullptr;
}
void fputs(const std::exception& e, FILE* f) {
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index b0c604e8c4..49917a342b 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -4,13 +4,13 @@
#include "strbuf.h"
#include "string.h"
#include "utility.h"
-#include "va_args.h"
+#include "va_args.h"
#include <utility>
-#include <util/stream/tempbuf.h>
-#include <util/system/compat.h>
-#include <util/system/compiler.h>
-#include <util/system/defaults.h>
+#include <util/stream/tempbuf.h>
+#include <util/system/compat.h>
+#include <util/system/compiler.h>
+#include <util/system/defaults.h>
#include <util/system/error.h>
#include <util/system/src_location.h>
#include <util/system/platform.h>
@@ -39,30 +39,30 @@ namespace NPrivateException {
class yexception: public std::exception {
public:
- yexception();
- yexception(const yexception&) = default;
- yexception(yexception&&) = default;
-
- yexception& operator=(const yexception&) = default;
- yexception& operator=(yexception&&) = default;
-
+ yexception();
+ yexception(const yexception&) = default;
+ yexception(yexception&&) = default;
+
+ yexception& operator=(const yexception&) = default;
+ yexception& operator=(yexception&&) = default;
+
const char* what() const noexcept override;
virtual const TBackTrace* BackTrace() const noexcept;
template <class T>
inline void Append(const T& t) {
TTempBufCuttingWrapperOutput tempBuf(Buf_);
- static_cast<IOutputStream&>(tempBuf) << t;
- ZeroTerminate();
+ static_cast<IOutputStream&>(tempBuf) << t;
+ ZeroTerminate();
}
- TStringBuf AsStrBuf() const;
-
- private:
- void ZeroTerminate() noexcept;
+ TStringBuf AsStrBuf() const;
private:
- TTempBuf Buf_;
+ void ZeroTerminate() noexcept;
+
+ private:
+ TTempBuf Buf_;
};
template <class E, class T>
@@ -82,7 +82,7 @@ namespace NPrivateException {
class yexception: public NPrivateException::yexception {
};
-Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) {
+Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) {
stream << value.AsStrBuf();
}
@@ -175,13 +175,13 @@ std::string CurrentExceptionTypeName();
TString FormatExc(const std::exception& exception);
-#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
- ythrow THROW_EXPRESSION; \
- } \
+#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
+ ythrow THROW_EXPRESSION; \
+ } \
} 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.
@@ -195,25 +195,25 @@ TString FormatExc(const std::exception& exception);
} 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_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)
-/**
- * @def Y_ENSURE
- *
- * This macro is inteded to use as a shortcut for `if () { throw }`.
- *
- * @code
- * void DoSomethingLovely(const int x, const int y) {
- * Y_ENSURE(x > y, "`x` must be greater than `y`");
- * Y_ENSURE(x > y); // if you are too lazy
- * // actually doing something nice here
- * }
- * @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
+ *
+ * This macro is inteded to use as a shortcut for `if () { throw }`.
+ *
+ * @code
+ * void DoSomethingLovely(const int x, const int y) {
+ * Y_ENSURE(x > y, "`x` must be greater than `y`");
+ * Y_ENSURE(x > y); // if you are too lazy
+ * // actually doing something nice here
+ * }
+ * @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
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index cb3e29fed8..81fb0f19da 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -13,7 +13,7 @@ static inline void Throw2DontMove() {
#include <util/generic/algorithm.h>
#include <util/memory/tempbuf.h>
#include <util/random/mersenne.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/string/subst.h>
#include "yexception_ut.h"
@@ -27,7 +27,7 @@ static void CallbackFun(int i) {
throw i;
}
-static IOutputStream* OUTS = nullptr;
+static IOutputStream* OUTS = nullptr;
namespace NOuter::NInner {
void Compare10And20() {
@@ -49,7 +49,7 @@ class TExceptionTest: public TTestBase {
UNIT_TEST(TestEnsureWithBackTrace1)
UNIT_TEST(TestEnsureWithBackTrace2)
UNIT_TEST(TestRethrowAppend)
- UNIT_TEST(TestMacroOverload)
+ UNIT_TEST(TestMacroOverload)
UNIT_TEST(TestMessageCrop)
UNIT_TEST(TestTIoSystemErrorSpecialMethods)
UNIT_TEST(TestCurrentExceptionTypeNameMethod)
@@ -260,26 +260,26 @@ private:
UNIT_ASSERT_VALUES_EQUAL(i, N);
}
}
-
- void TestMacroOverload() {
- try {
- Y_ENSURE(10 > 20);
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
- }
-
- try {
- Y_ENSURE(10 > 20, "exception message to search for");
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for"));
- }
+
+ void TestMacroOverload() {
+ try {
+ Y_ENSURE(10 > 20);
+ } catch (const yexception& e) {
+ UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
+ }
+
+ try {
+ Y_ENSURE(10 > 20, "exception message to search for");
+ } 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"));
}
- }
+ }
void TestMessageCrop() {
TTempBuf tmp;
@@ -293,7 +293,7 @@ private:
}
yexception e;
e << s;
- UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1));
+ UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1));
}
}
diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h
index fe42b4dfc0..f6964b8a6a 100644
--- a/util/generic/ylimits.h
+++ b/util/generic/ylimits.h
@@ -8,12 +8,12 @@
template <class T>
static constexpr T Max() noexcept {
- return std::numeric_limits<T>::max();
+ return std::numeric_limits<T>::max();
}
template <class T>
static constexpr T Min() noexcept {
- return std::numeric_limits<T>::min();
+ return std::numeric_limits<T>::min();
}
namespace NPrivate {
diff --git a/util/generic/ylimits_ut.cpp b/util/generic/ylimits_ut.cpp
index f1b3c6858c..60dc5c5390 100644
--- a/util/generic/ylimits_ut.cpp
+++ b/util/generic/ylimits_ut.cpp
@@ -34,7 +34,7 @@ static inline bool ValidSignInfo(bool limitIsSigned, const T&) {
template <class T>
static inline bool TestIntegralLimits(const T&, bool unknownSign = true, bool isSigned = true) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
CHECK_COND(lim::is_specialized);
CHECK_COND(lim::is_integer);
@@ -66,7 +66,7 @@ static inline bool TestUnsignedIntegralLimits(const T& val) {
template <class T>
static inline bool TestFloatLimits(const T&) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
CHECK_COND(lim::is_specialized);
CHECK_COND(!lim::is_modulo);
@@ -96,7 +96,7 @@ static inline bool TestFloatLimits(const T&) {
template <class T>
static inline bool TestNan(const T&) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
if (lim::has_quiet_NaN) {
const T qnan = lim::quiet_NaN();
diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp
index 31270728f4..c7dfc0260a 100644
--- a/util/generic/ymath.cpp
+++ b/util/generic/ymath.cpp
@@ -11,8 +11,8 @@ float Exp2f(float x) {
#ifdef _MSC_VER
double Erf(double x) {
- static constexpr double _M_2_SQRTPI = 1.12837916709551257390;
- static constexpr double eps = 1.0e-7;
+ static constexpr double _M_2_SQRTPI = 1.12837916709551257390;
+ static constexpr double eps = 1.0e-7;
if (fabs(x) >= 3.75)
return x > 0 ? 1.0 : -1.0;
double r = _M_2_SQRTPI * x;
@@ -29,12 +29,12 @@ double Erf(double x) {
#endif // _MSC_VER
double LogGammaImpl(double x) {
- static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI))
- static constexpr double coeff9 = 1.0 / 1188.0;
- static constexpr double coeff7 = -1.0 / 1680.0;
- static constexpr double coeff5 = 1.0 / 1260.0;
- static constexpr double coeff3 = -1.0 / 360.0;
- static constexpr double coeff1 = 1.0 / 12.0;
+ static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI))
+ static constexpr double coeff9 = 1.0 / 1188.0;
+ static constexpr double coeff7 = -1.0 / 1680.0;
+ static constexpr double coeff5 = 1.0 / 1260.0;
+ static constexpr double coeff3 = -1.0 / 360.0;
+ static constexpr double coeff1 = 1.0 / 12.0;
if ((x == 1.0) || (x == 2.0)) {
return 0.0; // 0! = 1
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 9ff9ae2abe..5fe17e2608 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -10,9 +10,9 @@
#include "typetraits.h"
#include "utility.h"
-constexpr double PI = M_PI;
-constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10)
-constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e)
+constexpr double PI = M_PI;
+constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10)
+constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e)
/**
* \returns Absolute value of the provided argument.
@@ -42,7 +42,7 @@ inline float Log2(float value) {
* @returns Base 2 logarithm of the provided integral value.
*/
template <class T>
-inline std::enable_if_t<std::is_integral<T>::value, double>
+inline std::enable_if_t<std::is_integral<T>::value, double>
Log2(T value) {
return Log2(static_cast<double>(value));
}
@@ -52,7 +52,7 @@ double Exp2(double);
float Exp2f(float);
template <class T>
-static constexpr T Sqr(const T t) noexcept {
+static constexpr T Sqr(const T t) noexcept {
return t * t;
}
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 29190b55eb..cf4f7cd5f7 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -3,14 +3,14 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/datetime/cputimer.h>
#include <limits>
template <class T>
static inline T SlowClp2(T t) noexcept {
- Y_ASSERT(t > 0);
+ Y_ASSERT(t > 0);
T ret = 1;