aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authordimanne <dimanne@yandex-team.ru>2022-02-10 16:49:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:48 +0300
commit93d66104be406c5b8cdfce7be5546d72d83b547e (patch)
tree5b4284b97105f480aa2b1ffc564e8f8e5b689df9 /util
parentb3eef5b52437f05851a3e8fb489a68db0132657b (diff)
downloadydb-93d66104be406c5b8cdfce7be5546d72d83b547e.tar.gz
Restoring authorship annotation for <dimanne@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/generic/flags.h26
-rw-r--r--util/generic/flags_ut.cpp60
-rw-r--r--util/system/atomic_ops.h14
3 files changed, 50 insertions, 50 deletions
diff --git a/util/generic/flags.h b/util/generic/flags.h
index a1f5921d42..246434e5a8 100644
--- a/util/generic/flags.h
+++ b/util/generic/flags.h
@@ -107,11 +107,11 @@ public:
}
constexpr friend bool operator==(TEnum l, TFlags r) {
- return static_cast<TInt>(l) == r.Value_;
+ return static_cast<TInt>(l) == r.Value_;
}
constexpr friend bool operator==(TFlags l, TEnum r) {
- return l.Value_ == static_cast<TInt>(r);
+ return l.Value_ == static_cast<TInt>(r);
}
constexpr friend bool operator!=(TFlags l, TFlags r) {
@@ -119,11 +119,11 @@ public:
}
constexpr friend bool operator!=(TEnum l, TFlags r) {
- return static_cast<TInt>(l) != r.Value_;
+ return static_cast<TInt>(l) != r.Value_;
}
constexpr friend bool operator!=(TFlags l, TEnum r) {
- return l.Value_ != static_cast<TInt>(r);
+ return l.Value_ != static_cast<TInt>(r);
}
TFlags& operator&=(TFlags mask) {
@@ -168,15 +168,15 @@ public:
return Value_;
}
- constexpr bool HasFlags(TFlags flags) const {
- return (Value_ & flags.Value_) == flags.Value_;
- }
-
- TFlags RemoveFlags(TFlags flags) {
- Value_ &= ~flags.Value_;
- return *this;
- }
-
+ constexpr bool HasFlags(TFlags flags) const {
+ return (Value_ & flags.Value_) == flags.Value_;
+ }
+
+ TFlags RemoveFlags(TFlags flags) {
+ Value_ &= ~flags.Value_;
+ return *this;
+ }
+
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..e115ffabe8 100644
--- a/util/generic/flags_ut.cpp
+++ b/util/generic/flags_ut.cpp
@@ -34,36 +34,36 @@ namespace {
Y_UNIT_TEST_SUITE(TFlagsTest) {
template <class Enum>
void TestEnum() {
- {
- auto i = Enum::Test1 | Enum::Test2;
-
- UNIT_ASSERT((std::is_same<decltype(i), TFlags<Enum>>::value));
- UNIT_ASSERT((std::is_same<decltype(~i), TFlags<Enum>>::value));
- UNIT_ASSERT(!(std::is_same<decltype(i), int>::value));
- UNIT_ASSERT_VALUES_EQUAL(sizeof(Enum), sizeof(TFlags<Enum>));
-
- UNIT_ASSERT(i.HasFlags(Enum::Test1));
- UNIT_ASSERT(i.HasFlags(Enum::Test4) == false);
- UNIT_ASSERT(i.HasFlags(Enum::Test1 | Enum::Test4) == false);
-
- i |= Enum::Test4;
- i ^= Enum::Test2;
- UNIT_ASSERT_EQUAL(i, Enum::Test4 | Enum::Test1);
- UNIT_ASSERT_EQUAL(i & Enum::Test1, i & ~Enum::Test4);
- UNIT_ASSERT(i & Enum::Test4);
- UNIT_ASSERT_UNEQUAL(i, ~i);
- UNIT_ASSERT_EQUAL(i, ~~i);
- }
- {
- auto i = Enum::Test1 | Enum::Test2;
- i.RemoveFlags(Enum::Test1);
- UNIT_ASSERT_EQUAL(i, TFlags<Enum>(Enum::Test2));
- }
- {
- auto i = Enum::Test1 | Enum::Test2;
- i.RemoveFlags(Enum::Test1 | Enum::Test2);
- UNIT_ASSERT_EQUAL(i, TFlags<Enum>());
- }
+ {
+ auto i = Enum::Test1 | Enum::Test2;
+
+ UNIT_ASSERT((std::is_same<decltype(i), TFlags<Enum>>::value));
+ UNIT_ASSERT((std::is_same<decltype(~i), TFlags<Enum>>::value));
+ UNIT_ASSERT(!(std::is_same<decltype(i), int>::value));
+ UNIT_ASSERT_VALUES_EQUAL(sizeof(Enum), sizeof(TFlags<Enum>));
+
+ UNIT_ASSERT(i.HasFlags(Enum::Test1));
+ UNIT_ASSERT(i.HasFlags(Enum::Test4) == false);
+ UNIT_ASSERT(i.HasFlags(Enum::Test1 | Enum::Test4) == false);
+
+ i |= Enum::Test4;
+ i ^= Enum::Test2;
+ UNIT_ASSERT_EQUAL(i, Enum::Test4 | Enum::Test1);
+ UNIT_ASSERT_EQUAL(i & Enum::Test1, i & ~Enum::Test4);
+ UNIT_ASSERT(i & Enum::Test4);
+ UNIT_ASSERT_UNEQUAL(i, ~i);
+ UNIT_ASSERT_EQUAL(i, ~~i);
+ }
+ {
+ auto i = Enum::Test1 | Enum::Test2;
+ i.RemoveFlags(Enum::Test1);
+ UNIT_ASSERT_EQUAL(i, TFlags<Enum>(Enum::Test2));
+ }
+ {
+ auto i = Enum::Test1 | Enum::Test2;
+ i.RemoveFlags(Enum::Test1 | Enum::Test2);
+ UNIT_ASSERT_EQUAL(i, TFlags<Enum>());
+ }
}
Y_UNIT_TEST(TestFlags) {
diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h
index 76766b4a0a..6ee569cb68 100644
--- a/util/system/atomic_ops.h
+++ b/util/system/atomic_ops.h
@@ -131,10 +131,10 @@ inline void AtomicSet(T* volatile& target, T* value) {
AtomicSet(*AsAtomicPtr(&target), reinterpret_cast<TAtomicBase>(value));
}
-using TNullPtr = decltype(nullptr);
-
+using TNullPtr = decltype(nullptr);
+
template <typename T>
-inline void AtomicSet(T* volatile& target, TNullPtr) {
+inline void AtomicSet(T* volatile& target, TNullPtr) {
AtomicSet(*AsAtomicPtr(&target), 0);
}
@@ -144,7 +144,7 @@ inline T* AtomicSwap(T* volatile* target, T* exchange) {
}
template <typename T>
-inline T* AtomicSwap(T* volatile* target, TNullPtr) {
+inline T* AtomicSwap(T* volatile* target, TNullPtr) {
return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), 0));
}
@@ -159,7 +159,7 @@ inline T* AtomicGetAndCas(T* volatile* target, T* exchange, T* compare) {
}
template <typename T>
-inline bool AtomicCas(T* volatile* target, T* exchange, TNullPtr) {
+inline bool AtomicCas(T* volatile* target, T* exchange, TNullPtr) {
return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0);
}
@@ -169,7 +169,7 @@ inline T* AtomicGetAndCas(T* volatile* target, T* exchange, TNullPtr) {
}
template <typename T>
-inline bool AtomicCas(T* volatile* target, TNullPtr, T* compare) {
+inline bool AtomicCas(T* volatile* target, TNullPtr, T* compare) {
return AtomicCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare));
}
@@ -179,7 +179,7 @@ inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, T* compare) {
}
template <typename T>
-inline bool AtomicCas(T* volatile* target, TNullPtr, TNullPtr) {
+inline bool AtomicCas(T* volatile* target, TNullPtr, TNullPtr) {
return AtomicCas(AsAtomicPtr(target), 0, 0);
}