aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.ru>2022-02-10 16:45:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:49 +0300
commit7489e4682331202b9c7d863c0898eb83d7b12c2b (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /util/generic
parenta5950576e397b1909261050b8c7da16db58f10b1 (diff)
downloadydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/cast.h4
-rw-r--r--util/generic/hash.h2
-rw-r--r--util/generic/hash_primes.h2
-rw-r--r--util/generic/hide_ptr.cpp10
-rw-r--r--util/generic/hide_ptr.h6
-rw-r--r--util/generic/maybe.h160
-rw-r--r--util/generic/ptr.h2
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/string.h26
-rw-r--r--util/generic/string_ut.cpp8
-rw-r--r--util/generic/typetraits.h12
-rw-r--r--util/generic/typetraits_ut.cpp2
-rw-r--r--util/generic/vector_ut.cpp80
-rw-r--r--util/generic/ymath.h2
14 files changed, 159 insertions, 159 deletions
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 6d273a9e43..0d4a41f385 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -124,7 +124,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
}
}
- TSmallInt smallInt = TSmallInt(largeInt);
+ TSmallInt smallInt = TSmallInt(largeInt);
if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
if (IsNegative(smallInt)) {
@@ -134,7 +134,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
}
}
- if (TLargeInt(smallInt) != largeInt) {
+ if (TLargeInt(smallInt) != largeInt) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
<< TypeName<TSmallInt>() << "', loss of data";
}
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 0a396f9b9e..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -494,7 +494,7 @@ private:
/* This method is templated to postpone instantiation of key extraction functor. */
template <class ValueL>
- auto get_key(const ValueL& value) const -> decltype(ExtractKey()(value)) {
+ auto get_key(const ValueL& value) const -> decltype(ExtractKey()(value)) {
return this->_get_key_extract()(value);
}
diff --git a/util/generic/hash_primes.h b/util/generic/hash_primes.h
index 15ffc3e484..4dc2da0b8f 100644
--- a/util/generic/hash_primes.h
+++ b/util/generic/hash_primes.h
@@ -24,7 +24,7 @@ namespace NPrivate {
/// @see https://gmplib.org/~tege/divcnst-pldi94.pdf
template <typename TDivisor, typename TDividend, typename MulUnsignedUpper>
class TReciprocalDivisor {
- static_assert(sizeof(TDivisor) <= sizeof(TDividend), "TDivisor and TDividend should have the same size");
+ static_assert(sizeof(TDivisor) <= sizeof(TDividend), "TDivisor and TDividend should have the same size");
public:
constexpr TReciprocalDivisor() noexcept = default;
diff --git a/util/generic/hide_ptr.cpp b/util/generic/hide_ptr.cpp
index 58837b6d90..74eac028aa 100644
--- a/util/generic/hide_ptr.cpp
+++ b/util/generic/hide_ptr.cpp
@@ -1,5 +1,5 @@
-#include "hide_ptr.h"
-
-void* HidePointerOrigin(void* ptr) {
- return ptr;
-}
+#include "hide_ptr.h"
+
+void* HidePointerOrigin(void* ptr) {
+ return ptr;
+}
diff --git a/util/generic/hide_ptr.h b/util/generic/hide_ptr.h
index ea415c46aa..c734894bd7 100644
--- a/util/generic/hide_ptr.h
+++ b/util/generic/hide_ptr.h
@@ -1,3 +1,3 @@
-#pragma once
-
-void* HidePointerOrigin(void*);
+#pragma once
+
+void* HidePointerOrigin(void*);
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index f250a893f9..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -50,107 +50,107 @@ private:
"Instantiation of TMaybe with non-destructible type is ill-formed");
template <class U>
- struct TConstructibleFromMaybeSomehow {
- public:
- static constexpr bool value = std::is_constructible<T, TMaybe<U, Policy>&>::value ||
- std::is_constructible<T, const TMaybe<U, Policy>&>::value ||
- std::is_constructible<T, TMaybe<U, Policy>&&>::value ||
- std::is_constructible<T, const TMaybe<U, Policy>&&>::value ||
- std::is_convertible<TMaybe<U, Policy>&, T>::value ||
- std::is_convertible<const TMaybe<U, Policy>&, T>::value ||
- std::is_convertible<TMaybe<U, Policy>&&, T>::value ||
- std::is_convertible<const TMaybe<U, Policy>&&, T>::value;
- };
+ struct TConstructibleFromMaybeSomehow {
+ public:
+ static constexpr bool value = std::is_constructible<T, TMaybe<U, Policy>&>::value ||
+ std::is_constructible<T, const TMaybe<U, Policy>&>::value ||
+ std::is_constructible<T, TMaybe<U, Policy>&&>::value ||
+ std::is_constructible<T, const TMaybe<U, Policy>&&>::value ||
+ std::is_convertible<TMaybe<U, Policy>&, T>::value ||
+ std::is_convertible<const TMaybe<U, Policy>&, T>::value ||
+ std::is_convertible<TMaybe<U, Policy>&&, T>::value ||
+ std::is_convertible<const TMaybe<U, Policy>&&, T>::value;
+ };
template <class U>
- struct TAssignableFromMaybeSomehow {
- public:
- static constexpr bool value = TConstructibleFromMaybeSomehow<U>::value ||
- std::is_assignable<T&, TMaybe<U, Policy>&>::value ||
- std::is_assignable<T&, const TMaybe<U, Policy>&>::value ||
- std::is_assignable<T&, TMaybe<U, Policy>&&>::value ||
- std::is_assignable<T&, const TMaybe<U, Policy>&&>::value;
- };
+ struct TAssignableFromMaybeSomehow {
+ public:
+ static constexpr bool value = TConstructibleFromMaybeSomehow<U>::value ||
+ std::is_assignable<T&, TMaybe<U, Policy>&>::value ||
+ std::is_assignable<T&, const TMaybe<U, Policy>&>::value ||
+ std::is_assignable<T&, TMaybe<U, Policy>&&>::value ||
+ std::is_assignable<T&, const TMaybe<U, Policy>&&>::value;
+ };
template <class U>
- struct TImplicitCopyCtor {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- std::is_convertible<const U&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TImplicitCopyCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ std::is_convertible<const U&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TExplicitCopyCtor {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- !std::is_convertible<const U&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TExplicitCopyCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ !std::is_convertible<const U&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TImplicitMoveCtor {
- public:
- static constexpr bool value = std::is_constructible<T, U&&>::value &&
- std::is_convertible<U&&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TImplicitMoveCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, U&&>::value &&
+ std::is_convertible<U&&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TExplicitMoveCtor {
- public:
- static constexpr bool value = std::is_constructible<T, U&&>::value &&
- !std::is_convertible<U&&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TExplicitMoveCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, U&&>::value &&
+ !std::is_convertible<U&&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TCopyAssignable {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- std::is_assignable<T&, const U&>::value &&
- !TAssignableFromMaybeSomehow<U>::value;
- };
+ struct TCopyAssignable {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ std::is_assignable<T&, const U&>::value &&
+ !TAssignableFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TMoveAssignable {
- public:
+ struct TMoveAssignable {
+ public:
static constexpr bool value = std::is_constructible<T, U&&>::value &&
std::is_assignable<T&, U&&>::value &&
!TAssignableFromMaybeSomehow<U>::value;
- };
+ };
- template <class U>
- struct TImplicitAnyCtor {
- public:
- using UDec = std::decay_t<U>;
+ template <class U>
+ struct TImplicitAnyCtor {
+ public:
+ using UDec = std::decay_t<U>;
+
+ static constexpr bool value = std::is_constructible<T, U>::value &&
+ std::is_convertible<U, T>::value &&
+ !std::is_same<UDec, TInPlace>::value &&
+ !std::is_same<UDec, TMaybe>::value;
+ };
- static constexpr bool value = std::is_constructible<T, U>::value &&
- std::is_convertible<U, T>::value &&
- !std::is_same<UDec, TInPlace>::value &&
- !std::is_same<UDec, TMaybe>::value;
- };
+ template <class U>
+ struct TExplicitAnyCtor {
+ public:
+ using UDec = std::decay_t<U>;
+ static constexpr bool value = std::is_constructible<T, U>::value &&
+ !std::is_convertible<U, T>::value &&
+ !std::is_same<UDec, TInPlace>::value &&
+ !std::is_same<UDec, TMaybe>::value;
+ };
template <class U>
- struct TExplicitAnyCtor {
- public:
- using UDec = std::decay_t<U>;
- static constexpr bool value = std::is_constructible<T, U>::value &&
- !std::is_convertible<U, T>::value &&
- !std::is_same<UDec, TInPlace>::value &&
- !std::is_same<UDec, TMaybe>::value;
- };
-
- template <class U>
- struct TAssignableFromAny {
- public:
- using UDec = std::decay_t<U>;
- static constexpr bool value = !std::is_same<UDec, TMaybe>::value &&
- std::is_constructible<T, U>::value &&
- std::is_assignable<T&, U>::value &&
- (!std::is_scalar<T>::value || !std::is_same<UDec, T>::value);
- };
-
+ struct TAssignableFromAny {
+ public:
+ using UDec = std::decay_t<U>;
+ static constexpr bool value = !std::is_same<UDec, TMaybe>::value &&
+ std::is_constructible<T, U>::value &&
+ std::is_assignable<T&, U>::value &&
+ (!std::is_scalar<T>::value || !std::is_same<UDec, T>::value);
+ };
+
using TBase = TMaybeBase<T>;
public:
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 27b72cafdd..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -303,7 +303,7 @@ public:
DoSwap(T_, r.T_);
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 846db66785..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -523,7 +523,7 @@ public:
inline size_t find_first_not_of(const TStringView set, size_t pos) const noexcept {
return AsStringView().find_first_not_of(set.data(), pos, set.size());
}
-
+
inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept {
return find_last_of(&c, pos, 1);
}
diff --git a/util/generic/string.h b/util/generic/string.h
index ae2f213dbd..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -119,13 +119,13 @@ public:
}
TChar* operator&() {
- return S_.begin() + Pos_;
- }
-
+ return S_.begin() + Pos_;
+ }
+
const TChar* operator&() const {
- return S_.cbegin() + Pos_;
- }
-
+ return S_.cbegin() + Pos_;
+ }
+
TBasicCharRef& operator=(TChar c) {
Y_ASSERT(Pos_ < S_.size() || (Pos_ == S_.size() && !c));
@@ -1215,15 +1215,15 @@ TBasicString<TCharType> to_title(const TBasicString<TCharType, TTraits>& s) {
return ret;
}
-namespace std {
+namespace std {
template <>
- struct hash<TString> {
- using argument_type = TString;
- using result_type = size_t;
- inline result_type operator()(argument_type const& s) const noexcept {
+ struct hash<TString> {
+ using argument_type = TString;
+ using result_type = size_t;
+ inline result_type operator()(argument_type const& s) const noexcept {
return NHashPrivate::ComputeStringHash(s.data(), s.size());
- }
- };
+ }
+ };
}
#undef Y_NOEXCEPT
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index 7e255c687a..ac82e9091d 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -584,16 +584,16 @@ protected:
void find_last_of() {
// 21.3.6.4
TStringType s(Data_.one_two_three_one_two_three());
-
+
UNIT_ASSERT(s.find_last_of(Data_.abcde()) == 26);
UNIT_ASSERT(s.find_last_of(TStringType(Data_.abcde())) == 26);
-
+
TStringType test(Data_.aba());
-
+
UNIT_ASSERT(test.find_last_of(Data_.a(), 2, 1) == 2);
UNIT_ASSERT(test.find_last_of(Data_.a(), 1, 1) == 0);
UNIT_ASSERT(test.find_last_of(Data_.a(), 0, 1) == 0);
-
+
UNIT_ASSERT(test.find_last_of(*Data_.a(), 2) == 2);
UNIT_ASSERT(test.find_last_of(*Data_.a(), 1) == 0);
UNIT_ASSERT(test.find_last_of(*Data_.a(), 0) == 0);
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index bd67c874c8..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -48,8 +48,8 @@ namespace NPrivate {
}
}
-#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
-// Disable std::conjunction for MSVC by analogy with std::disjunction.
+#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
+// Disable std::conjunction for MSVC by analogy with std::disjunction.
template <class... Bs>
using TConjunction = std::conjunction<Bs...>;
#else
@@ -57,10 +57,10 @@ template <class... Bs>
struct TConjunction: ::TBoolConstant<::NPrivate::ConjunctionImpl<Bs...>()> {};
#endif
-#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
-// Disable std::disjunction for MSVC.
-// It reduces build time (500 -> 20 seconds) and memory consumption (20 GB -> less than 1 GB)
-// for some files (notably search/dssm_boosting/dssm_boosting_calcer.cpp).
+#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
+// Disable std::disjunction for MSVC.
+// It reduces build time (500 -> 20 seconds) and memory consumption (20 GB -> less than 1 GB)
+// for some files (notably search/dssm_boosting/dssm_boosting_calcer.cpp).
template <class... Bs>
using TDisjunction = std::disjunction<Bs...>;
#else
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index f021f9e0b0..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -60,7 +60,7 @@ namespace {
class TNonStdLayoutClass2 {
public:
virtual void Func() {
- }
+ }
};
class TNonStdLayoutClass3: public TNonStdLayoutClass2 {
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 359bbcceb2..0f6b4037a0 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -27,7 +27,7 @@ class TYVectorTest: public TTestBase {
UNIT_TEST(TestShrink)
//UNIT_TEST(TestEbo)
UNIT_TEST(TestFillInConstructor)
- UNIT_TEST(TestYResize)
+ UNIT_TEST(TestYResize)
UNIT_TEST(TestCrop)
UNIT_TEST(TestInitializeList)
UNIT_TEST_SUITE_END();
@@ -470,45 +470,45 @@ private:
}
}
}
-
- struct TPod {
- int x;
+
+ struct TPod {
+ int x;
operator int() {
return x;
}
- };
-
- struct TNonPod {
- int x;
- TNonPod() {
- x = 0;
- }
+ };
+
+ struct TNonPod {
+ int x;
+ TNonPod() {
+ x = 0;
+ }
operator int() {
return x;
}
- };
-
+ };
+
template <typename T>
class TDebugAlloc: public std::allocator<T> {
- public:
- using TBase = std::allocator<T>;
-
+ public:
+ using TBase = std::allocator<T>;
+
T* allocate(typename TBase::size_type n) {
auto p = TBase::allocate(n);
- for (size_t i = 0; i < n; ++i) {
- memset(p + i, 0xab, sizeof(T));
- }
- return p;
- }
-
+ for (size_t i = 0; i < n; ++i) {
+ memset(p + i, 0xab, sizeof(T));
+ }
+ return p;
+ }
+
template <class TOther>
- struct rebind {
+ struct rebind {
using other = TDebugAlloc<TOther>;
- };
- };
-
+ };
+ };
+
template <typename T>
void TestYResize() {
#ifdef _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED
@@ -518,23 +518,23 @@ private:
#endif
TVector<T, TDebugAlloc<T>> v;
-
- v.reserve(5);
+
+ v.reserve(5);
auto firstBegin = v.begin();
-
+
v.yresize(5); // No realloc, no initialization if allowed
- UNIT_ASSERT(firstBegin == v.begin());
- for (int i = 0; i < 5; ++i) {
+ UNIT_ASSERT(firstBegin == v.begin());
+ for (int i = 0; i < 5; ++i) {
UNIT_ASSERT_VALUES_EQUAL(bool(v[i]), ALLOW_UNINITIALIZED);
- }
-
+ }
+
v.yresize(20); // Realloc, still no initialization
- UNIT_ASSERT(firstBegin != v.begin());
- for (int i = 0; i < 20; ++i) {
+ UNIT_ASSERT(firstBegin != v.begin());
+ for (int i = 0; i < 20; ++i) {
UNIT_ASSERT_VALUES_EQUAL(bool(v[i]), ALLOW_UNINITIALIZED);
- }
- }
-
+ }
+ }
+
struct TNoDefaultConstructor {
TNoDefaultConstructor() = delete;
explicit TNoDefaultConstructor(int val)
@@ -558,11 +558,11 @@ private:
UNIT_ASSERT(vec[0].Val == 42);
}
- void TestYResize() {
+ void TestYResize() {
TestYResize<int>();
TestYResize<TPod>();
TestYResize<TNonPod>();
- }
+ }
void CheckInitializeList(const TVector<int>& v) {
for (size_t i = 0; i < v.size(); ++i) {
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 745d1c03a9..9ff9ae2abe 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -84,7 +84,7 @@ static inline bool IsNan(double f) {
#if defined(_win_)
return _isnan(f) != 0;
#else
- return std::isnan(f);
+ return std::isnan(f);
#endif
}