aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authortender-bum <tender-bum@yandex-team.ru>2022-02-10 16:50:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:01 +0300
commit4aef354b224559d2b031487a10d4f5cc6e82e95a (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util
parentc78b06a63de7beec995c1007bc5332bdf3d75b69 (diff)
downloadydb-4aef354b224559d2b031487a10d4f5cc6e82e95a.tar.gz
Restoring authorship annotation for <tender-bum@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/digest/numeric.h2
-rw-r--r--util/draft/holder_vector.h6
-rw-r--r--util/draft/holder_vector_ut.cpp2
-rw-r--r--util/generic/algorithm.h66
-rw-r--r--util/generic/algorithm_ut.cpp34
-rw-r--r--util/generic/bitops.h8
-rw-r--r--util/generic/hash.h10
-rw-r--r--util/generic/intrlist.h2
-rw-r--r--util/generic/is_in.h2
-rw-r--r--util/generic/maybe.h218
-rw-r--r--util/generic/maybe_traits.h300
-rw-r--r--util/generic/maybe_ut.cpp98
-rw-r--r--util/generic/overloaded.cpp2
-rw-r--r--util/generic/overloaded.h16
-rw-r--r--util/generic/overloaded_ut.cpp74
-rw-r--r--util/generic/ptr_ut.cpp6
-rw-r--r--util/generic/serialized_enum_ut.cpp10
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/typelist.h54
-rw-r--r--util/generic/typelist_ut.cpp18
-rw-r--r--util/generic/typetraits.h88
-rw-r--r--util/generic/typetraits_ut.cpp18
-rw-r--r--util/generic/utility.h32
-rw-r--r--util/generic/variant.h8
-rw-r--r--util/memory/blob.cpp32
-rw-r--r--util/memory/blob.h16
-rw-r--r--util/network/address.cpp2
-rw-r--r--util/network/address.h2
-rw-r--r--util/string/split.h12
-rw-r--r--util/system/event_ut.cpp10
-rw-r--r--util/system/fasttime.cpp6
-rw-r--r--util/system/filemap_ut.cpp4
-rw-r--r--util/system/tls.cpp2
-rw-r--r--util/system/tls.h2
-rw-r--r--util/system/types.cpp2
-rw-r--r--util/thread/factory.cpp4
-rw-r--r--util/thread/factory.h6
-rw-r--r--util/thread/factory_ut.cpp4
-rw-r--r--util/thread/lfqueue.h2
-rw-r--r--util/thread/pool.cpp14
-rw-r--r--util/thread/pool.h6
-rw-r--r--util/thread/pool_ut.cpp2
-rw-r--r--util/ysaveload.h98
43 files changed, 651 insertions, 651 deletions
diff --git a/util/digest/numeric.h b/util/digest/numeric.h
index 6bbdd894cf..e20bd908e4 100644
--- a/util/digest/numeric.h
+++ b/util/digest/numeric.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/typelist.h>
+#include <util/generic/typelist.h>
#include <util/system/defaults.h>
/*
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index 942f4b718b..1c62055bd9 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -41,15 +41,15 @@ public:
}
}
- void PushBack(std::unique_ptr<T> t) {
+ void PushBack(std::unique_ptr<T> t) {
PushBack(t.release());
}
- void PushBack(THolder<T> t) {
+ void PushBack(THolder<T> t) {
PushBack(t.Release());
}
- void Reset(size_t i, THolder<T> t) {
+ void Reset(size_t i, THolder<T> t) {
T* current = (*this)[i];
if (current) {
Y_ASSERT(current != t.Get());
diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp
index 9f3b9a919c..f64393860a 100644
--- a/util/draft/holder_vector_ut.cpp
+++ b/util/draft/holder_vector_ut.cpp
@@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
ints.Resize(2);
THolder<int> holder(new int(1));
- ints.Reset(0, std::move(holder));
+ ints.Reset(0, std::move(holder));
UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
UNIT_ASSERT(!holder);
}
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index 221e4c6ad0..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -454,27 +454,27 @@ static inline void Rotate(T f, T m, T l) {
}
template <typename It, typename Val>
-Val Accumulate(It begin, It end, Val val) {
- // std::move since C++20
- return std::accumulate(begin, end, std::move(val));
+Val Accumulate(It begin, It end, Val val) {
+ // std::move since C++20
+ return std::accumulate(begin, end, std::move(val));
}
template <typename It, typename Val, typename BinOp>
-Val Accumulate(It begin, It end, Val val, BinOp binOp) {
- // std::move since C++20
- return std::accumulate(begin, end, std::move(val), binOp);
+Val Accumulate(It begin, It end, Val val, BinOp binOp) {
+ // std::move since C++20
+ return std::accumulate(begin, end, std::move(val), binOp);
}
-template <typename C, typename Val>
-Val Accumulate(const C& c, Val val) {
- // std::move since C++20
- return Accumulate(std::begin(c), std::end(c), std::move(val));
+template <typename C, typename Val>
+Val Accumulate(const C& c, Val val) {
+ // std::move since C++20
+ return Accumulate(std::begin(c), std::end(c), std::move(val));
}
-template <typename C, typename Val, typename BinOp>
-Val Accumulate(const C& c, Val val, BinOp binOp) {
- // std::move since C++20
- return Accumulate(std::begin(c), std::end(c), std::move(val), binOp);
+template <typename C, typename Val, typename BinOp>
+Val Accumulate(const C& c, Val val, BinOp binOp) {
+ // std::move since C++20
+ return Accumulate(std::begin(c), std::end(c), std::move(val), binOp);
}
template <typename It1, typename It2, typename Val>
@@ -549,19 +549,19 @@ auto MinElementBy(const C& c, F&& func) {
return MinElementBy(std::begin(c), std::end(c), std::forward<F>(func));
}
-template <class TOp, class... TArgs>
-void ApplyToMany(TOp op, TArgs&&... args) {
+template <class TOp, class... TArgs>
+void ApplyToMany(TOp op, TArgs&&... args) {
int dummy[] = {((void)op(std::forward<TArgs>(args)), 0)...};
- Y_UNUSED(dummy);
-}
-
+ Y_UNUSED(dummy);
+}
+
template <class TI, class TOp>
-inline void ForEach(TI f, TI l, TOp op) {
+inline void ForEach(TI f, TI l, TOp op) {
std::for_each(f, l, op);
}
-namespace NPrivate {
- template <class T, class TOp, size_t... Is>
+namespace NPrivate {
+ template <class T, class TOp, size_t... Is>
constexpr bool AllOfImpl(T&& t, TOp&& op, std::index_sequence<Is...>) {
#if _LIBCPP_STD_VER >= 17
return (true && ... && op(std::get<Is>(std::forward<T>(t))));
@@ -592,13 +592,13 @@ namespace NPrivate {
#if _LIBCPP_STD_VER >= 17
(..., op(std::get<Is>(std::forward<T>(t))));
#else
- ::ApplyToMany(std::forward<TOp>(op), std::get<Is>(std::forward<T>(t))...);
+ ::ApplyToMany(std::forward<TOp>(op), std::get<Is>(std::forward<T>(t))...);
#endif
- }
-}
-
+ }
+}
+
// check that TOp return true for all of element from tuple T
-template <class T, class TOp>
+template <class T, class TOp>
constexpr ::TEnableIfTuple<T, bool> AllOf(T&& t, TOp&& op) {
return ::NPrivate::AllOfImpl(
std::forward<T>(t),
@@ -617,12 +617,12 @@ constexpr ::TEnableIfTuple<T, bool> AnyOf(T&& t, TOp&& op) {
template <class T, class TOp>
constexpr ::TEnableIfTuple<T> ForEach(T&& t, TOp&& op) {
- ::NPrivate::ForEachImpl(
- std::forward<T>(t),
- std::forward<TOp>(op),
- std::make_index_sequence<std::tuple_size<std::decay_t<T>>::value>{});
-}
-
+ ::NPrivate::ForEachImpl(
+ std::forward<T>(t),
+ std::forward<TOp>(op),
+ std::make_index_sequence<std::tuple_size<std::decay_t<T>>::value>{});
+}
+
template <class T1, class T2, class O>
static inline void Transform(T1 b, T1 e, T2 o, O f) {
std::transform(b, e, o, f);
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 632677a3c4..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -696,12 +696,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
MinElementBy(empty, functor);
}
- Y_UNIT_TEST(TestApplyToMany) {
- int res = 0;
- ApplyToMany([&res](auto v) { res += v; }, 1, 2, 3, 4, 5);
- UNIT_ASSERT_EQUAL(res, 15);
-
- struct TVisitor {
+ Y_UNIT_TEST(TestApplyToMany) {
+ int res = 0;
+ ApplyToMany([&res](auto v) { res += v; }, 1, 2, 3, 4, 5);
+ UNIT_ASSERT_EQUAL(res, 15);
+
+ struct TVisitor {
TVisitor(int& acc)
: Acc(acc)
{
@@ -712,20 +712,20 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
void operator()(int v) {
Acc += v * 2;
};
- int& Acc;
- };
+ int& Acc;
+ };
TString s{"8-800-555-35-35"};
ApplyToMany(TVisitor{res = 0}, 1, s, 5, s);
- UNIT_ASSERT_EQUAL(res, 12 + 2 * static_cast<int>(s.size()));
- }
-
- Y_UNIT_TEST(TestTupleForEach) {
+ UNIT_ASSERT_EQUAL(res, 12 + 2 * static_cast<int>(s.size()));
+ }
+
+ Y_UNIT_TEST(TestTupleForEach) {
ForEach(std::tuple<>{}, [&](auto) { UNIT_ASSERT(false); });
- auto t = std::make_tuple(5, 6, 2, 3, 6);
- ForEach(t, [](auto& v) { v *= -1; });
- UNIT_ASSERT_EQUAL(t, std::make_tuple(-5, -6, -2, -3, -6));
- }
-
+ auto t = std::make_tuple(5, 6, 2, 3, 6);
+ ForEach(t, [](auto& v) { v *= -1; });
+ UNIT_ASSERT_EQUAL(t, std::make_tuple(-5, -6, -2, -3, -6));
+ }
+
Y_UNIT_TEST(TestTupleAllOf) {
UNIT_ASSERT(AllOf(std::tuple<>{}, [](auto) { return false; }));
UNIT_ASSERT(!AllOf(std::make_tuple(1, 2, 0, 4, 5), [&](auto v) { UNIT_ASSERT_LT(v, 3); return 0 != v; }));
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index a1862b1d61..2db15fc59b 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -1,7 +1,7 @@
#pragma once
#include "ylimits.h"
-#include "typelist.h"
+#include "typelist.h"
#include <util/system/compiler.h>
#include <util/system/yassert.h>
@@ -208,7 +208,7 @@ namespace NBitOps {
template <typename T>
static inline T FastClp2(T t) noexcept {
Y_ASSERT(t > 0);
- using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+ 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));
}
@@ -226,7 +226,7 @@ Y_CONST_FUNCTION constexpr bool IsPowerOf2(T v) noexcept {
template <typename T>
static inline unsigned GetValueBitCount(T value) noexcept {
Y_ASSERT(value > 0);
- using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+ using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
}
@@ -236,7 +236,7 @@ static inline unsigned GetValueBitCount(T value) noexcept {
template <typename T>
static inline unsigned CountTrailingZeroBits(T value) noexcept {
Y_ASSERT(value > 0);
- using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+ using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
}
diff --git a/util/generic/hash.h b/util/generic/hash.h
index c6478487d5..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -615,10 +615,10 @@ public:
deinitialize_buckets(buckets);
}
- size_type size() const noexcept {
+ size_type size() const noexcept {
return num_elements;
}
- size_type max_size() const noexcept {
+ size_type max_size() const noexcept {
return size_type(-1);
}
@@ -1521,13 +1521,13 @@ public:
// See hash_ut.cpp
public:
- size_type size() const noexcept {
+ size_type size() const noexcept {
return rep.size();
}
- yssize_t ysize() const noexcept {
+ yssize_t ysize() const noexcept {
return (yssize_t)rep.size();
}
- size_type max_size() const noexcept {
+ size_type max_size() const noexcept {
return rep.max_size();
}
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index 26967cea57..b5d3f2051b 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -857,7 +857,7 @@ public:
}
template <class TFunctor>
- inline void ForEach(TFunctor&& functor) const noexcept(noexcept(functor(std::declval<TListItem>().Node()))) {
+ inline void ForEach(TFunctor&& functor) const noexcept(noexcept(functor(std::declval<TListItem>().Node()))) {
TListItem* i = Begin_;
while (i) {
diff --git a/util/generic/is_in.h b/util/generic/is_in.h
index 59d687dc7a..4f175ea5eb 100644
--- a/util/generic/is_in.h
+++ b/util/generic/is_in.h
@@ -17,7 +17,7 @@ namespace NIsInHelper {
Y_HAS_SUBTYPE(key_type, KeyType);
template <class T>
- using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>;
+ using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>;
template <class C, class T, bool isAssoc>
struct TIsInTraits {
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index b47d6f4cab..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -1,8 +1,8 @@
#pragma once
#include <utility>
-
-#include "maybe_traits.h"
+
+#include "maybe_traits.h"
#include "yexception.h"
#include <util/system/align.h>
@@ -37,17 +37,17 @@ constexpr bool operator==(TNothing, TNothing) noexcept {
template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/>
class TMaybe: private TMaybeBase<T> {
public:
- using TInPlace = NMaybe::TInPlace;
-
-private:
- static_assert(!std::is_same<std::remove_cv_t<T>, TNothing>::value,
- "Instantiation of TMaybe with a TNothing type is ill-formed");
- static_assert(!std::is_same<std::remove_cv_t<T>, TInPlace>::value,
- "Instantiation of TMaybe with a TInPlace type is ill-formed");
- static_assert(!std::is_reference<T>::value,
- "Instantiation of TMaybe with reference type is ill-formed");
- static_assert(std::is_destructible<T>::value,
- "Instantiation of TMaybe with non-destructible type is ill-formed");
+ using TInPlace = NMaybe::TInPlace;
+
+private:
+ static_assert(!std::is_same<std::remove_cv_t<T>, TNothing>::value,
+ "Instantiation of TMaybe with a TNothing type is ill-formed");
+ static_assert(!std::is_same<std::remove_cv_t<T>, TInPlace>::value,
+ "Instantiation of TMaybe with a TInPlace type is ill-formed");
+ static_assert(!std::is_reference<T>::value,
+ "Instantiation of TMaybe with reference type is ill-formed");
+ static_assert(std::is_destructible<T>::value,
+ "Instantiation of TMaybe with non-destructible type is ill-formed");
template <class U>
struct TConstructibleFromMaybeSomehow {
@@ -72,66 +72,66 @@ private:
std::is_assignable<T&, const TMaybe<U, Policy>&&>::value;
};
- template <class U>
+ 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;
};
-
- template <class U>
+
+ 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;
};
-
- template <class U>
+
+ 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;
};
-
- template <class U>
+
+ 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;
};
-
- template <class U>
+
+ 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;
};
-
- template <class U>
+
+ template <class U>
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>;
-
+
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>
+
+ template <class U>
struct TExplicitAnyCtor {
public:
using UDec = std::decay_t<U>;
@@ -140,7 +140,7 @@ private:
!std::is_same<UDec, TInPlace>::value &&
!std::is_same<UDec, TMaybe>::value;
};
-
+
template <class U>
struct TAssignableFromAny {
public:
@@ -151,23 +151,23 @@ private:
(!std::is_scalar<T>::value || !std::is_same<UDec, T>::value);
};
- using TBase = TMaybeBase<T>;
+ using TBase = TMaybeBase<T>;
+
+public:
+ using value_type = T;
+ using TValueType = value_type;
-public:
- using value_type = T;
- using TValueType = value_type;
+ TMaybe() noexcept = default;
- TMaybe() noexcept = default;
+ constexpr TMaybe(const TMaybe&) = default;
+ constexpr TMaybe(TMaybe&&) = default;
- constexpr TMaybe(const TMaybe&) = default;
- constexpr TMaybe(TMaybe&&) = default;
-
- template <class... Args>
- constexpr explicit TMaybe(TInPlace, Args&&... args)
+ template <class... Args>
+ constexpr explicit TMaybe(TInPlace, Args&&... args)
: TBase(TInPlace{}, std::forward<Args>(args)...)
{
}
-
+
template <class U, class... TArgs>
constexpr explicit TMaybe(TInPlace, std::initializer_list<U> il, TArgs&&... args)
: TBase(TInPlace{}, il, std::forward<TArgs>(args)...)
@@ -177,77 +177,77 @@ public:
constexpr TMaybe(TNothing) noexcept {
}
- template <class U, class = std::enable_if_t<TImplicitCopyCtor<U>::value>>
- TMaybe(const TMaybe<U, Policy>& right) {
- if (right.Defined()) {
+ template <class U, class = std::enable_if_t<TImplicitCopyCtor<U>::value>>
+ TMaybe(const TMaybe<U, Policy>& right) {
+ if (right.Defined()) {
new (Data()) T(right.GetRef());
- this->Defined_ = true;
+ this->Defined_ = true;
}
}
- template <class U, std::enable_if_t<TExplicitCopyCtor<U>::value, bool> = false>
- explicit TMaybe(const TMaybe<U, Policy>& right) {
- if (right.Defined()) {
+ template <class U, std::enable_if_t<TExplicitCopyCtor<U>::value, bool> = false>
+ explicit TMaybe(const TMaybe<U, Policy>& right) {
+ if (right.Defined()) {
new (Data()) T(right.GetRef());
- this->Defined_ = true;
+ this->Defined_ = true;
}
}
- template <class U, class = std::enable_if_t<TImplicitMoveCtor<U>::value>>
- TMaybe(TMaybe<U, Policy>&& right) noexcept(std::is_nothrow_constructible<T, U&&>::value) {
- if (right.Defined()) {
+ template <class U, class = std::enable_if_t<TImplicitMoveCtor<U>::value>>
+ TMaybe(TMaybe<U, Policy>&& right) noexcept(std::is_nothrow_constructible<T, U&&>::value) {
+ if (right.Defined()) {
new (Data()) T(std::move(right.GetRef()));
- this->Defined_ = true;
+ this->Defined_ = true;
}
}
- template <class U, std::enable_if_t<TExplicitMoveCtor<U>::value, bool> = false>
- explicit TMaybe(TMaybe<U, Policy>&& right) noexcept(std::is_nothrow_constructible<T, U&&>::value) {
- if (right.Defined()) {
+ template <class U, std::enable_if_t<TExplicitMoveCtor<U>::value, bool> = false>
+ explicit TMaybe(TMaybe<U, Policy>&& right) noexcept(std::is_nothrow_constructible<T, U&&>::value) {
+ if (right.Defined()) {
new (Data()) T(std::move(right.GetRef()));
- this->Defined_ = true;
+ this->Defined_ = true;
}
}
- template <class U = T, class = std::enable_if_t<TImplicitAnyCtor<U>::value>>
- constexpr TMaybe(U&& right)
+ template <class U = T, class = std::enable_if_t<TImplicitAnyCtor<U>::value>>
+ constexpr TMaybe(U&& right)
: TBase(TInPlace{}, std::forward<U>(right))
{
}
-
- template <class U = T, std::enable_if_t<TExplicitAnyCtor<U>::value, bool> = false>
- constexpr explicit TMaybe(U&& right)
+
+ template <class U = T, std::enable_if_t<TExplicitAnyCtor<U>::value, bool> = false>
+ constexpr explicit TMaybe(U&& right)
: TBase(TInPlace{}, std::forward<U>(right))
{
}
-
- ~TMaybe() = default;
- constexpr TMaybe& operator=(const TMaybe&) = default;
- constexpr TMaybe& operator=(TMaybe&&) = default;
+ ~TMaybe() = default;
- TMaybe& operator=(TNothing) noexcept {
+ constexpr TMaybe& operator=(const TMaybe&) = default;
+ constexpr TMaybe& operator=(TMaybe&&) = default;
+
+ TMaybe& operator=(TNothing) noexcept {
Clear();
return *this;
}
- template <class U = T>
- std::enable_if_t<TAssignableFromAny<U>::value, TMaybe&> operator=(U&& right) {
+ template <class U = T>
+ std::enable_if_t<TAssignableFromAny<U>::value, TMaybe&> operator=(U&& right) {
if (Defined()) {
- *Data() = std::forward<U>(right);
+ *Data() = std::forward<U>(right);
} else {
- Init(std::forward<U>(right));
+ Init(std::forward<U>(right));
}
return *this;
}
- template <class U>
- std::enable_if_t<TCopyAssignable<U>::value,
+ template <class U>
+ std::enable_if_t<TCopyAssignable<U>::value,
TMaybe&>
operator=(const TMaybe<U, Policy>& right) {
if (right.Defined()) {
if (Defined()) {
- *Data() = right.GetRef();
+ *Data() = right.GetRef();
} else {
Init(right.GetRef());
}
@@ -258,15 +258,15 @@ public:
return *this;
}
- template <class U>
- std::enable_if_t<TMoveAssignable<U>::value,
+ template <class U>
+ std::enable_if_t<TMoveAssignable<U>::value,
TMaybe&>
operator=(TMaybe<U, Policy>&& right) noexcept(
std::is_nothrow_assignable<T&, U&&>::value&& std::is_nothrow_constructible<T, U&&>::value)
- {
+ {
if (right.Defined()) {
if (Defined()) {
- *Data() = std::move(right.GetRef());
+ *Data() = std::move(right.GetRef());
} else {
Init(std::move(right.GetRef()));
}
@@ -277,39 +277,39 @@ public:
return *this;
}
- template <typename... Args>
- T& ConstructInPlace(Args&&... args) {
- Clear();
- Init(std::forward<Args>(args)...);
- return *Data();
- }
-
- void Clear() noexcept {
+ template <typename... Args>
+ T& ConstructInPlace(Args&&... args) {
+ Clear();
+ Init(std::forward<Args>(args)...);
+ return *Data();
+ }
+
+ void Clear() noexcept {
if (Defined()) {
- this->Defined_ = false;
+ this->Defined_ = false;
Data()->~T();
}
}
- constexpr bool Defined() const noexcept {
- return this->Defined_;
+ constexpr bool Defined() const noexcept {
+ return this->Defined_;
}
Y_PURE_FUNCTION constexpr bool Empty() const noexcept {
return !Defined();
}
- void CheckDefined() const {
+ void CheckDefined() const {
if (Y_UNLIKELY(!Defined())) {
Policy::OnEmpty(typeid(TValueType));
}
}
- const T* Get() const noexcept {
+ const T* Get() const noexcept {
return Defined() ? Data() : nullptr;
}
- T* Get() noexcept {
+ T* Get() noexcept {
return Defined() ? Data() : nullptr;
}
@@ -353,27 +353,27 @@ public:
return std::move(GetRef());
}
- constexpr const T* operator->() const {
+ constexpr const T* operator->() const {
return &GetRef();
}
- constexpr T* operator->() {
+ constexpr T* operator->() {
return &GetRef();
}
- constexpr const T& GetOrElse(const T& elseValue) const {
+ constexpr const T& GetOrElse(const T& elseValue) const {
return Defined() ? *Data() : elseValue;
}
- constexpr T& GetOrElse(T& elseValue) {
+ constexpr T& GetOrElse(T& elseValue) {
return Defined() ? *Data() : elseValue;
}
- constexpr const TMaybe& OrElse(const TMaybe& elseValue) const noexcept {
+ constexpr const TMaybe& OrElse(const TMaybe& elseValue) const noexcept {
return Defined() ? *this : elseValue;
}
- constexpr TMaybe& OrElse(TMaybe& elseValue) {
+ constexpr TMaybe& OrElse(TMaybe& elseValue) {
return Defined() ? *this : elseValue;
}
@@ -383,7 +383,7 @@ public:
}
constexpr explicit operator bool() const noexcept {
- return Defined();
+ return Defined();
}
void Save(IOutputStream* out) const {
@@ -392,7 +392,7 @@ public:
::Save<bool>(out, defined);
if (defined) {
- ::Save(out, *Data());
+ ::Save(out, *Data());
}
}
@@ -406,13 +406,13 @@ public:
ConstructInPlace();
}
- ::Load(in, *Data());
+ ::Load(in, *Data());
} else {
Clear();
}
}
- void Swap(TMaybe& other) {
+ void Swap(TMaybe& other) {
if (this->Defined_ == other.Defined_) {
if (this->Defined_) {
::DoSwap(this->Data_, other.Data_);
@@ -428,23 +428,23 @@ public:
}
}
- void swap(TMaybe& other) {
+ void swap(TMaybe& other) {
Swap(other);
}
private:
- constexpr const T* Data() const noexcept {
- return std::addressof(this->Data_);
+ constexpr const T* Data() const noexcept {
+ return std::addressof(this->Data_);
}
- constexpr T* Data() noexcept {
- return std::addressof(this->Data_);
+ constexpr T* Data() noexcept {
+ return std::addressof(this->Data_);
}
template <typename... Args>
- void Init(Args&&... args) {
+ void Init(Args&&... args) {
new (Data()) T(std::forward<Args>(args)...);
- this->Defined_ = true;
+ this->Defined_ = true;
}
};
@@ -712,7 +712,7 @@ constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) {
class IOutputStream;
template <class T, class TPolicy>
-inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) {
+inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) {
if (maybe.Defined()) {
out << *maybe;
} else {
diff --git a/util/generic/maybe_traits.h b/util/generic/maybe_traits.h
index d507d8fa34..9e9f56955e 100644
--- a/util/generic/maybe_traits.h
+++ b/util/generic/maybe_traits.h
@@ -1,173 +1,173 @@
-#pragma once
-
+#pragma once
+
#include <memory>
-#include <type_traits>
-#include <initializer_list>
-
-namespace NMaybe {
- struct TInPlace {};
-
- template <class T, bool = std::is_trivially_destructible<T>::value>
- struct TStorageBase {
- constexpr TStorageBase() noexcept
+#include <type_traits>
+#include <initializer_list>
+
+namespace NMaybe {
+ struct TInPlace {};
+
+ template <class T, bool = std::is_trivially_destructible<T>::value>
+ struct TStorageBase {
+ constexpr TStorageBase() noexcept
: NullState_('\0')
{
}
-
- template <class... Args>
- constexpr TStorageBase(TInPlace, Args&&... args)
- : Data_(std::forward<Args>(args)...)
+
+ template <class... Args>
+ constexpr TStorageBase(TInPlace, Args&&... args)
+ : Data_(std::forward<Args>(args)...)
, Defined_(true)
{
}
-
- ~TStorageBase() = default;
-
- union {
- char NullState_;
- T Data_;
- };
- bool Defined_ = false;
- };
-
- template <class T>
- struct TStorageBase<T, false> {
- constexpr TStorageBase() noexcept
+
+ ~TStorageBase() = default;
+
+ union {
+ char NullState_;
+ T Data_;
+ };
+ bool Defined_ = false;
+ };
+
+ template <class T>
+ struct TStorageBase<T, false> {
+ constexpr TStorageBase() noexcept
: NullState_('\0')
{
}
-
- template <class... Args>
- constexpr TStorageBase(TInPlace, Args&&... args)
- : Data_(std::forward<Args>(args)...)
+
+ template <class... Args>
+ constexpr TStorageBase(TInPlace, Args&&... args)
+ : Data_(std::forward<Args>(args)...)
, Defined_(true)
{
}
-
- ~TStorageBase() {
- if (this->Defined_) {
- this->Data_.~T();
- }
- }
-
- union {
- char NullState_;
- T Data_;
- };
- bool Defined_ = false;
- };
-
- // -------------------- COPY CONSTRUCT --------------------
-
- template <class T, bool = std::is_trivially_copy_constructible<T>::value>
+
+ ~TStorageBase() {
+ if (this->Defined_) {
+ this->Data_.~T();
+ }
+ }
+
+ union {
+ char NullState_;
+ T Data_;
+ };
+ bool Defined_ = false;
+ };
+
+ // -------------------- COPY CONSTRUCT --------------------
+
+ template <class T, bool = std::is_trivially_copy_constructible<T>::value>
struct TCopyBase: TStorageBase<T> {
- using TStorageBase<T>::TStorageBase;
- };
-
- template <class T>
+ using TStorageBase<T>::TStorageBase;
+ };
+
+ template <class T>
struct TCopyBase<T, false>: TStorageBase<T> {
- using TStorageBase<T>::TStorageBase;
-
- constexpr TCopyBase() = default;
- constexpr TCopyBase(const TCopyBase& rhs) {
- if (rhs.Defined_) {
- new (std::addressof(this->Data_)) T(rhs.Data_);
- this->Defined_ = true;
- }
- }
- constexpr TCopyBase(TCopyBase&&) = default;
- TCopyBase& operator=(const TCopyBase&) = default;
- TCopyBase& operator=(TCopyBase&&) = default;
- };
-
- // -------------------- MOVE CONSTRUCT --------------------
-
- template <class T, bool = std::is_trivially_move_constructible<T>::value>
+ using TStorageBase<T>::TStorageBase;
+
+ constexpr TCopyBase() = default;
+ constexpr TCopyBase(const TCopyBase& rhs) {
+ if (rhs.Defined_) {
+ new (std::addressof(this->Data_)) T(rhs.Data_);
+ this->Defined_ = true;
+ }
+ }
+ constexpr TCopyBase(TCopyBase&&) = default;
+ TCopyBase& operator=(const TCopyBase&) = default;
+ TCopyBase& operator=(TCopyBase&&) = default;
+ };
+
+ // -------------------- MOVE CONSTRUCT --------------------
+
+ template <class T, bool = std::is_trivially_move_constructible<T>::value>
struct TMoveBase: TCopyBase<T> {
- using TCopyBase<T>::TCopyBase;
- };
-
- template <class T>
+ using TCopyBase<T>::TCopyBase;
+ };
+
+ template <class T>
struct TMoveBase<T, false>: TCopyBase<T> {
- using TCopyBase<T>::TCopyBase;
-
- constexpr TMoveBase() noexcept = default;
- constexpr TMoveBase(const TMoveBase&) = default;
- constexpr TMoveBase(TMoveBase&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value) {
- if (rhs.Defined_) {
- new (std::addressof(this->Data_)) T(std::move(rhs.Data_));
- this->Defined_ = true;
- }
- }
- TMoveBase& operator=(const TMoveBase&) = default;
- TMoveBase& operator=(TMoveBase&&) = default;
- };
-
- // -------------------- COPY ASSIGN --------------------
-
- template <class T, bool = std::is_trivially_copy_assignable<T>::value>
+ using TCopyBase<T>::TCopyBase;
+
+ constexpr TMoveBase() noexcept = default;
+ constexpr TMoveBase(const TMoveBase&) = default;
+ constexpr TMoveBase(TMoveBase&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value) {
+ if (rhs.Defined_) {
+ new (std::addressof(this->Data_)) T(std::move(rhs.Data_));
+ this->Defined_ = true;
+ }
+ }
+ TMoveBase& operator=(const TMoveBase&) = default;
+ TMoveBase& operator=(TMoveBase&&) = default;
+ };
+
+ // -------------------- COPY ASSIGN --------------------
+
+ template <class T, bool = std::is_trivially_copy_assignable<T>::value>
struct TCopyAssignBase: TMoveBase<T> {
- using TMoveBase<T>::TMoveBase;
- };
-
- template <class T>
+ using TMoveBase<T>::TMoveBase;
+ };
+
+ template <class T>
struct TCopyAssignBase<T, false>: TMoveBase<T> {
- using TMoveBase<T>::TMoveBase;
-
- constexpr TCopyAssignBase() noexcept = default;
- constexpr TCopyAssignBase(const TCopyAssignBase&) = default;
- constexpr TCopyAssignBase(TCopyAssignBase&&) = default;
- TCopyAssignBase& operator=(const TCopyAssignBase& rhs) {
- if (this->Defined_) {
- if (rhs.Defined_) {
- this->Data_ = rhs.Data_;
- } else {
- this->Data_.~T();
- this->Defined_ = false;
- }
- } else if (rhs.Defined_) {
- new (std::addressof(this->Data_)) T(rhs.Data_);
- this->Defined_ = true;
- }
- return *this;
- }
- TCopyAssignBase& operator=(TCopyAssignBase&&) = default;
- };
-
- // -------------------- MOVE ASSIGN --------------------
-
- template <class T, bool = std::is_trivially_copy_assignable<T>::value>
+ using TMoveBase<T>::TMoveBase;
+
+ constexpr TCopyAssignBase() noexcept = default;
+ constexpr TCopyAssignBase(const TCopyAssignBase&) = default;
+ constexpr TCopyAssignBase(TCopyAssignBase&&) = default;
+ TCopyAssignBase& operator=(const TCopyAssignBase& rhs) {
+ if (this->Defined_) {
+ if (rhs.Defined_) {
+ this->Data_ = rhs.Data_;
+ } else {
+ this->Data_.~T();
+ this->Defined_ = false;
+ }
+ } else if (rhs.Defined_) {
+ new (std::addressof(this->Data_)) T(rhs.Data_);
+ this->Defined_ = true;
+ }
+ return *this;
+ }
+ TCopyAssignBase& operator=(TCopyAssignBase&&) = default;
+ };
+
+ // -------------------- MOVE ASSIGN --------------------
+
+ template <class T, bool = std::is_trivially_copy_assignable<T>::value>
struct TMoveAssignBase: TCopyAssignBase<T> {
- using TCopyAssignBase<T>::TCopyAssignBase;
- };
-
- template <class T>
+ using TCopyAssignBase<T>::TCopyAssignBase;
+ };
+
+ template <class T>
struct TMoveAssignBase<T, false>: TCopyAssignBase<T> {
- using TCopyAssignBase<T>::TCopyAssignBase;
-
- constexpr TMoveAssignBase() noexcept = default;
- constexpr TMoveAssignBase(const TMoveAssignBase&) = default;
- constexpr TMoveAssignBase(TMoveAssignBase&&) = default;
- TMoveAssignBase& operator=(const TMoveAssignBase&) = default;
- TMoveAssignBase& operator=(TMoveAssignBase&& rhs) noexcept(
+ using TCopyAssignBase<T>::TCopyAssignBase;
+
+ constexpr TMoveAssignBase() noexcept = default;
+ constexpr TMoveAssignBase(const TMoveAssignBase&) = default;
+ constexpr TMoveAssignBase(TMoveAssignBase&&) = default;
+ TMoveAssignBase& operator=(const TMoveAssignBase&) = default;
+ TMoveAssignBase& operator=(TMoveAssignBase&& rhs) noexcept(
std::is_nothrow_move_assignable<T>::value&&
std::is_nothrow_move_constructible<T>::value)
- {
- if (this->Defined_) {
- if (rhs.Defined_) {
- this->Data_ = std::move(rhs.Data_);
- } else {
- this->Data_.~T();
- this->Defined_ = false;
- }
- } else if (rhs.Defined_) {
- new (std::addressof(this->Data_)) T(std::move(rhs.Data_));
- this->Defined_ = true;
- }
- return *this;
- }
- };
-}
-
-template <class T>
-using TMaybeBase = NMaybe::TMoveAssignBase<T>;
+ {
+ if (this->Defined_) {
+ if (rhs.Defined_) {
+ this->Data_ = std::move(rhs.Data_);
+ } else {
+ this->Data_.~T();
+ this->Defined_ = false;
+ }
+ } else if (rhs.Defined_) {
+ new (std::addressof(this->Data_)) T(std::move(rhs.Data_));
+ this->Defined_ = true;
+ }
+ return *this;
+ }
+ };
+}
+
+template <class T>
+using TMaybeBase = NMaybe::TMoveAssignBase<T>;
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index 8eb9de6426..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -21,24 +21,24 @@ public:
};
Y_UNIT_TEST_SUITE(TMaybeTest) {
- Y_UNIT_TEST(TestStatic) {
- using T1 = TMaybe<int>;
- static_assert(std::is_trivially_copy_constructible<T1>::value, "");
- static_assert(std::is_trivially_destructible<T1>::value, "");
-
- using T2 = TMaybe<TString*>;
- static_assert(std::is_trivially_copy_constructible<T2>::value, "");
- static_assert(std::is_trivially_destructible<T2>::value, "");
-
- using T3 = TMaybe<TMaybe<double>>;
- static_assert(std::is_trivially_copy_constructible<T3>::value, "");
- static_assert(std::is_trivially_destructible<T3>::value, "");
-
- using T4 = TMaybe<TString>;
- static_assert(!std::is_trivially_copy_constructible<T4>::value, "");
- static_assert(!std::is_trivially_destructible<T4>::value, "");
- }
-
+ Y_UNIT_TEST(TestStatic) {
+ using T1 = TMaybe<int>;
+ static_assert(std::is_trivially_copy_constructible<T1>::value, "");
+ static_assert(std::is_trivially_destructible<T1>::value, "");
+
+ using T2 = TMaybe<TString*>;
+ static_assert(std::is_trivially_copy_constructible<T2>::value, "");
+ static_assert(std::is_trivially_destructible<T2>::value, "");
+
+ using T3 = TMaybe<TMaybe<double>>;
+ static_assert(std::is_trivially_copy_constructible<T3>::value, "");
+ static_assert(std::is_trivially_destructible<T3>::value, "");
+
+ using T4 = TMaybe<TString>;
+ static_assert(!std::is_trivially_copy_constructible<T4>::value, "");
+ static_assert(!std::is_trivially_destructible<T4>::value, "");
+ }
+
Y_UNIT_TEST(TestWarning) {
TMaybe<size_t> x;
TStringStream ss;
@@ -136,9 +136,9 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m5 == TMaybe<int>());
UNIT_ASSERT(m5 == Nothing());
UNIT_ASSERT(m5 != TMaybe<int>(5));
-
- m5 = {};
- UNIT_ASSERT(m5.Empty());
+
+ m5 = {};
+ UNIT_ASSERT(m5.Empty());
}
Y_UNIT_TEST(TestInPlace) {
@@ -964,40 +964,40 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_EQUAL(testStructMaybe.GetRef().From_, TestStruct::FromValue);
UNIT_ASSERT_EQUAL(testStructMaybe.GetRef().Value_, 23);
}
-
- Y_UNIT_TEST(TestMaybeConvertion) {
- struct TSrc {};
- struct TDst {
- bool FromMaybeConstructorApplied;
-
- explicit TDst(TSrc)
+
+ Y_UNIT_TEST(TestMaybeConvertion) {
+ struct TSrc {};
+ struct TDst {
+ bool FromMaybeConstructorApplied;
+
+ explicit TDst(TSrc)
: FromMaybeConstructorApplied(false)
{
}
-
- explicit TDst(TMaybe<TSrc>)
+
+ explicit TDst(TMaybe<TSrc>)
: FromMaybeConstructorApplied(true)
{
}
-
- TDst& operator=(TSrc) {
- FromMaybeConstructorApplied = false;
- return *this;
- }
- TDst& operator=(TMaybe<TSrc>) {
- FromMaybeConstructorApplied = true;
- return *this;
- }
- };
-
- auto m = TMaybe<TDst>(TMaybe<TSrc>());
- UNIT_ASSERT(m.Defined());
- UNIT_ASSERT(m->FromMaybeConstructorApplied);
-
- m = TMaybe<TSrc>();
- UNIT_ASSERT(m.Defined());
- UNIT_ASSERT(m->FromMaybeConstructorApplied);
- }
+
+ TDst& operator=(TSrc) {
+ FromMaybeConstructorApplied = false;
+ return *this;
+ }
+ TDst& operator=(TMaybe<TSrc>) {
+ FromMaybeConstructorApplied = true;
+ return *this;
+ }
+ };
+
+ auto m = TMaybe<TDst>(TMaybe<TSrc>());
+ UNIT_ASSERT(m.Defined());
+ UNIT_ASSERT(m->FromMaybeConstructorApplied);
+
+ m = TMaybe<TSrc>();
+ UNIT_ASSERT(m.Defined());
+ UNIT_ASSERT(m->FromMaybeConstructorApplied);
+ }
Y_UNIT_TEST(TestOnEmptyException) {
TMaybe<TStringBuf> v;
diff --git a/util/generic/overloaded.cpp b/util/generic/overloaded.cpp
index 7372126e41..fb6ff88d31 100644
--- a/util/generic/overloaded.cpp
+++ b/util/generic/overloaded.cpp
@@ -1 +1 @@
-#include "overloaded.h"
+#include "overloaded.h"
diff --git a/util/generic/overloaded.h b/util/generic/overloaded.h
index 848d48c712..96a97e44bc 100644
--- a/util/generic/overloaded.h
+++ b/util/generic/overloaded.h
@@ -1,5 +1,5 @@
-#pragma once
-
+#pragma once
+
/**
* Construct an ad-hoc object with an overloaded `operator()`.
*
@@ -47,10 +47,10 @@
* ```
*/
-template <class... Fs>
+template <class... Fs>
struct TOverloaded: Fs... {
- using Fs::operator()...;
-};
-
-template <class... Fs>
-TOverloaded(Fs...) -> TOverloaded<Fs...>;
+ using Fs::operator()...;
+};
+
+template <class... Fs>
+TOverloaded(Fs...) -> TOverloaded<Fs...>;
diff --git a/util/generic/overloaded_ut.cpp b/util/generic/overloaded_ut.cpp
index 43893808e5..f3d73895ad 100644
--- a/util/generic/overloaded_ut.cpp
+++ b/util/generic/overloaded_ut.cpp
@@ -1,55 +1,55 @@
#include <util/generic/overloaded.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/variant.h>
-#include <util/generic/algorithm.h>
-
-#include <tuple>
-
-namespace {
- struct TType1 {};
- struct TType2 {};
- struct TType3 {};
-}
-
-Y_UNIT_TEST_SUITE(TOverloadedTest) {
- Y_UNIT_TEST(StaticTest) {
- auto f = TOverloaded{
- [](const TType1&) {},
- [](const TType2&) {},
+
+#include <util/generic/variant.h>
+#include <util/generic/algorithm.h>
+
+#include <tuple>
+
+namespace {
+ struct TType1 {};
+ struct TType2 {};
+ struct TType3 {};
+}
+
+Y_UNIT_TEST_SUITE(TOverloadedTest) {
+ Y_UNIT_TEST(StaticTest) {
+ auto f = TOverloaded{
+ [](const TType1&) {},
+ [](const TType2&) {},
[](const TType3&) {}};
- using F = decltype(f);
- static_assert(std::is_invocable_v<F, TType1>);
- static_assert(std::is_invocable_v<F, TType2>);
- static_assert(std::is_invocable_v<F, TType3>);
- static_assert(!std::is_invocable_v<F, int>);
- static_assert(!std::is_invocable_v<F, double>);
- }
-
- Y_UNIT_TEST(VariantTest) {
+ using F = decltype(f);
+ static_assert(std::is_invocable_v<F, TType1>);
+ static_assert(std::is_invocable_v<F, TType2>);
+ static_assert(std::is_invocable_v<F, TType3>);
+ static_assert(!std::is_invocable_v<F, int>);
+ static_assert(!std::is_invocable_v<F, double>);
+ }
+
+ Y_UNIT_TEST(VariantTest) {
std::variant<int, double, TType1> v = 5;
- int res = 0;
+ int res = 0;
std::visit(TOverloaded{
[&](int val) { res = val; },
[&](double) { res = -1; },
[&](TType1) { res = -1; }},
v);
UNIT_ASSERT_VALUES_EQUAL(res, 5);
- }
-
- Y_UNIT_TEST(TupleTest) {
+ }
+
+ Y_UNIT_TEST(TupleTest) {
std::tuple<int, double, bool, int> t{5, 3.14, true, 20};
- TString res;
-
- ForEach(t, TOverloaded{
+ TString res;
+
+ ForEach(t, TOverloaded{
[&](int val) { res += "(int) " + ToString(val) + ' '; },
[&](double val) { res += "(double) " + ToString(val) + ' '; },
[&](bool val) { res += "(bool) " + ToString(val) + ' '; },
});
-
+
UNIT_ASSERT_VALUES_EQUAL(res, "(int) 5 (double) 3.14 (bool) 1 (int) 20 ");
- }
+ }
Y_UNIT_TEST(ImplicitConversionsTest) {
using TTestVariant = std::variant<int, double, char>;
@@ -79,4 +79,4 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) {
UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{12345}), 12345.0);
UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{'X'}), 88.0);
}
-}
+}
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index 29bee493b5..c2dcff23f6 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -204,9 +204,9 @@ void TPointerTest::TestMakeHolder() {
{
struct TRec {
int X, Y;
- TRec(int x, int y)
- : X(x)
- , Y(y)
+ TRec(int x, int y)
+ : X(x)
+ , Y(y)
{
}
};
diff --git a/util/generic/serialized_enum_ut.cpp b/util/generic/serialized_enum_ut.cpp
index 6420f83c27..3a94e1d471 100644
--- a/util/generic/serialized_enum_ut.cpp
+++ b/util/generic/serialized_enum_ut.cpp
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TestSerializedEnum) {
enum EEmpty {
};
- UNIT_ASSERT_C((TTypeList<int, unsigned>::THave<typename TSelectEnumRepresentationType<EEmpty>::TType>::value), "empty enum using signed or unsigned integer underlying type");
+ UNIT_ASSERT_C((TTypeList<int, unsigned>::THave<typename TSelectEnumRepresentationType<EEmpty>::TType>::value), "empty enum using signed or unsigned integer underlying type");
using TRepresentationTypeList = TTypeList<int, unsigned, long long, unsigned long long>;
@@ -29,22 +29,22 @@ Y_UNIT_TEST_SUITE(TestSerializedEnum) {
Two = 2,
Five = 5,
};
- UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ERegular>::TType>::value);
+ UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ERegular>::TType>::value);
enum class ESmall: unsigned char {
Six = 6,
};
- UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ESmall>::TType>::value);
+ UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ESmall>::TType>::value);
enum class EHugeUnsigned: ui64 {
Value = 0,
};
- UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeUnsigned>::TType>::value);
+ UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeUnsigned>::TType>::value);
enum class EHugeSigned: i64 {
Value = -2,
};
- UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeSigned>::TType>::value);
+ UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeSigned>::TType>::value);
}
Y_UNIT_TEST(MappedArrayView) {
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 56c974cca9..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -556,7 +556,7 @@ public:
return CopyImpl(pc, n, pos);
}
- inline size_t copy(TCharType* pc, size_t n) const noexcept {
+ inline size_t copy(TCharType* pc, size_t n) const noexcept {
return CopyImpl(pc, n, 0);
}
diff --git a/util/generic/typelist.h b/util/generic/typelist.h
index 06eaded7ab..5ce26ab97c 100644
--- a/util/generic/typelist.h
+++ b/util/generic/typelist.h
@@ -2,8 +2,8 @@
#include <util/system/types.h>
-#include <util/generic/typetraits.h>
-
+#include <util/generic/typetraits.h>
+
#include <type_traits>
template <class... R>
@@ -12,25 +12,25 @@ struct TTypeList;
namespace NTL {
template <unsigned N, typename TL>
struct TGetImpl {
- using type = typename TGetImpl<N - 1, typename TL::TTail>::type;
+ using type = typename TGetImpl<N - 1, typename TL::TTail>::type;
};
template <typename TL>
struct TGetImpl<0u, TL> {
- using type = typename TL::THead;
+ using type = typename TL::THead;
};
}
template <>
struct TTypeList<> {
- static constexpr size_t Length = 0;
+ static constexpr size_t Length = 0;
- template <class>
- using THave = std::false_type;
+ template <class>
+ using THave = std::false_type;
template <template <class> class P>
struct TSelectBy {
- using type = TTypeList<>;
+ using type = TTypeList<>;
};
};
@@ -41,17 +41,17 @@ struct TTypeList<H, R...> {
using THead = H;
using TTail = TTypeList<R...>;
- static constexpr size_t Length = 1 + sizeof...(R);
+ static constexpr size_t Length = 1 + sizeof...(R);
template <class V>
- using THave = TDisjunction<std::is_same<H, V>, typename TTail::template THave<V>>;
+ using THave = TDisjunction<std::is_same<H, V>, typename TTail::template THave<V>>;
template <unsigned N>
- using TGet = typename ::NTL::TGetImpl<N, TTypeList<H, R...>>::type;
+ using TGet = typename ::NTL::TGetImpl<N, TTypeList<H, R...>>::type;
template <template <class> class P>
struct TSelectBy {
- using type = std::conditional_t<P<THead>::value, THead, typename TTail::template TSelectBy<P>::type>;
+ using type = std::conditional_t<P<THead>::value, THead, typename TTail::template TSelectBy<P>::type>;
};
};
@@ -60,11 +60,11 @@ template <class T>
struct TTypeList<T, TNone>: public TTypeList<T> {
};
-using TCommonSignedInts = TTypeList<signed char, signed short, signed int, signed long, signed long long>;
-using TCommonUnsignedInts = TTypeList<unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, bool>;
-using TFixedWidthSignedInts = TTypeList<i8, i16, i32, i64>;
-using TFixedWidthUnsignedInts = TTypeList<ui8, ui16, ui32, ui64>;
-using TFloats = TTypeList<float, double, long double>;
+using TCommonSignedInts = TTypeList<signed char, signed short, signed int, signed long, signed long long>;
+using TCommonUnsignedInts = TTypeList<unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, bool>;
+using TFixedWidthSignedInts = TTypeList<i8, i16, i32, i64>;
+using TFixedWidthUnsignedInts = TTypeList<ui8, ui16, ui32, ui64>;
+using TFloats = TTypeList<float, double, long double>;
namespace NTL {
template <class T1, class T2>
@@ -72,19 +72,19 @@ namespace NTL {
template <class... R1, class... R2>
struct TConcat<TTypeList<R1...>, TTypeList<R2...>> {
- using type = TTypeList<R1..., R2...>;
+ using type = TTypeList<R1..., R2...>;
};
template <bool isSigned, class T, class TS, class TU>
struct TTypeSelectorBase {
- using TSignedInts = typename TConcat<TTypeList<T>, TS>::type;
+ using TSignedInts = typename TConcat<TTypeList<T>, TS>::type;
using TUnsignedInts = TU;
};
template <class T, class TS, class TU>
struct TTypeSelectorBase<false, T, TS, TU> {
using TSignedInts = TS;
- using TUnsignedInts = typename TConcat<TTypeList<T>, TU>::type;
+ using TUnsignedInts = typename TConcat<TTypeList<T>, TU>::type;
};
template <class T, class TS, class TU>
@@ -101,14 +101,14 @@ using TUnsignedInts = NTL::T2::TUnsignedInts;
template <unsigned sizeOf>
struct TSizeOfPredicate {
template <class T>
- using TResult = TBoolConstant<sizeof(T) == sizeOf>;
+ using TResult = TBoolConstant<sizeof(T) == sizeOf>;
};
-
-template <typename T>
-using TFixedWidthSignedInt = typename TFixedWidthSignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
-
-template <typename T>
-using TFixedWidthUnsignedInt = typename TFixedWidthUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+
+template <typename T>
+using TFixedWidthSignedInt = typename TFixedWidthSignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+
+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;
diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp
index 4c674bf0cb..eeabfa97b1 100644
--- a/util/generic/typelist_ut.cpp
+++ b/util/generic/typelist_ut.cpp
@@ -34,11 +34,11 @@ public:
struct TC {};
void TestHave() {
using TListType = TTypeList<TA, TB*, const TC&>;
- UNIT_ASSERT(TListType::THave<TA>::value);
- UNIT_ASSERT(TListType::THave<TB*>::value);
- UNIT_ASSERT(!TListType::THave<TB>::value);
- UNIT_ASSERT(TListType::THave<const TC&>::value);
- UNIT_ASSERT(!TListType::THave<TC&>::value);
+ UNIT_ASSERT(TListType::THave<TA>::value);
+ UNIT_ASSERT(TListType::THave<TB*>::value);
+ UNIT_ASSERT(!TListType::THave<TB>::value);
+ UNIT_ASSERT(TListType::THave<const TC&>::value);
+ UNIT_ASSERT(!TListType::THave<TC&>::value);
}
template <class T>
@@ -55,7 +55,7 @@ public:
template <template <class...> class TT, class... R>
struct TIsNArgTemplate<TT<R...>>: std::true_type {};
-
+
template <class>
struct TAnyType: std::true_type {};
@@ -68,10 +68,10 @@ public:
void TestSelectBy() {
using TListType = TTypeList<TA, TB, TMyMap<TA*, TB>, TMyVector<TA>, TC>;
- UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TAnyType>::type, TA);
- UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIs1ArgTemplate>::type, TMyVector<TA>);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TAnyType>::type, TA);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIs1ArgTemplate>::type, TMyVector<TA>);
using TMyMapPTATB = TMyMap<TA*, TB>;
- UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIsNArgTemplate>::type, TMyMapPTATB);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIsNArgTemplate>::type, TMyMapPTATB);
}
void TestFloatList() {
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index a1c7fa35c2..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -9,74 +9,74 @@
#include <stlfwd>
#if _LIBCPP_STD_VER >= 17
-template <bool B>
+template <bool B>
using TBoolConstant = std::bool_constant<B>;
#else
template <bool B>
struct TBoolConstant: std::integral_constant<bool, B> {};
#endif
-
+
#if _LIBCPP_STD_VER >= 17
-template <class B>
+template <class B>
using TNegation = std::negation<B>;
#else
template <class B>
struct TNegation: ::TBoolConstant<!bool(B::value)> {};
#endif
-
-namespace NPrivate {
- template <class... Bs>
- constexpr bool ConjunctionImpl() {
+
+namespace NPrivate {
+ template <class... Bs>
+ constexpr bool ConjunctionImpl() {
bool bs[] = {(bool)Bs::value...};
- for (auto b : bs) {
- if (!b) {
- return false;
- }
- }
- return true;
- }
-
- template <class... Bs>
- constexpr bool DisjunctionImpl() {
+ for (auto b : bs) {
+ if (!b) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ template <class... Bs>
+ constexpr bool DisjunctionImpl() {
bool bs[] = {(bool)Bs::value...};
- for (auto b : bs) {
- if (b) {
- return true;
- }
- }
- return false;
- }
-}
-
+ for (auto b : bs) {
+ if (b) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
// Disable std::conjunction for MSVC by analogy with std::disjunction.
-template <class... Bs>
+template <class... Bs>
using TConjunction = std::conjunction<Bs...>;
#else
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).
-template <class... Bs>
+template <class... Bs>
using TDisjunction = std::disjunction<Bs...>;
#else
template <class... Bs>
struct TDisjunction: ::TBoolConstant<::NPrivate::DisjunctionImpl<Bs...>()> {};
#endif
-
+
#if _LIBCPP_STD_VER >= 17
template <class... Bs>
using TVoidT = std::void_t<Bs...>;
#else
-template <class...>
-using TVoidT = void;
+template <class...>
+using TVoidT = void;
#endif
-
-template <class T>
+
+template <class T>
struct TPodTraits {
enum {
IsPod = false
@@ -160,7 +160,7 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
: std::integral_constant<bool, TClassHas##name<T>::value> {}; \
template <class T> \
struct THas##name \
- : TBaseHas##name<T, std::is_class<T>::value || std::is_union<T>::value> {}
+ : 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)
@@ -170,7 +170,7 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
* 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
+ * 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
@@ -179,13 +179,13 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
* Y_HAS_MEMBER(push_front, PushFront);
*
* template <typename T, typename U>
- * std::enable_if_t<THasPushFront<T>::value, void>
+ * std::enable_if_t<THasPushFront<T>::value, void>
* PushFront(T& container, const U value) {
* container.push_front(x);
* }
*
* template <typename T, typename U>
- * std::enable_if_t<!THasPushFront<T>::value, void>
+ * std::enable_if_t<!THasPushFront<T>::value, void>
* PushFront(T& container, const U value) {
* container.insert(container.begin(), x);
* }
@@ -207,7 +207,7 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
* 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
+ * 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
@@ -217,7 +217,7 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
*
* template <typename T>
* using TIsAssocCont = std::conditional_t<
- * THasFindMethod<T>::value && THasConstIterator<T>::value && THasKeyType<T>::value,
+ * THasFindMethod<T>::value && THasConstIterator<T>::value && THasKeyType<T>::value,
* std::true_type,
* std::false_type,
* >;
@@ -262,11 +262,11 @@ struct TIsPointerToConstMemberFunction<R (T::*)(Args..., ...) const&>: std::true
template <class R, class T, class... Args>
struct TIsPointerToConstMemberFunction<R (T::*)(Args..., ...) const&&>: std::true_type {
};
-
-template <template <class...> class T, class U>
+
+template <template <class...> class T, class U>
struct TIsSpecializationOf: std::false_type {};
-
-template <template <class...> class T, class... Ts>
+
+template <template <class...> class T, class... Ts>
struct TIsSpecializationOf<T, T<Ts...>>: std::true_type {};
/*
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index 24b7febc6f..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -2,9 +2,9 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <vector>
-#include <tuple>
-
+#include <vector>
+#include <tuple>
+
namespace {
enum ETestEnum {
};
@@ -450,12 +450,12 @@ 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, "");
-static_assert(TIsSpecializationOf<std::tuple, std::tuple<int, double, char>>::value, "");
-static_assert(!TIsSpecializationOf<std::vector, std::tuple<int, double, char>>::value, "");
-static_assert(!TIsSpecializationOf<std::pair, std::vector<int>>::value, "");
+
+// test for TIsSpecializationOf
+static_assert(TIsSpecializationOf<std::vector, std::vector<int>>::value, "");
+static_assert(TIsSpecializationOf<std::tuple, std::tuple<int, double, char>>::value, "");
+static_assert(!TIsSpecializationOf<std::vector, std::tuple<int, double, char>>::value, "");
+static_assert(!TIsSpecializationOf<std::pair, std::vector<int>>::value, "");
// test for TIsIterable
static_assert(TIsIterable<std::vector<int>>::value, "");
diff --git a/util/generic/utility.h b/util/generic/utility.h
index 75f63400d7..43b98eeafc 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -69,27 +69,27 @@ namespace NSwapCheck {
Y_HAS_MEMBER(swap);
Y_HAS_MEMBER(Swap);
- template <class T, class = void>
- struct TSwapSelector {
- static inline void Swap(T& l, T& r) noexcept(std::is_nothrow_move_constructible<T>::value&&
- std::is_nothrow_move_assignable<T>::value) {
- T tmp(std::move(l));
- l = std::move(r);
- r = std::move(tmp);
+ template <class T, class = void>
+ struct TSwapSelector {
+ static inline void Swap(T& l, T& r) noexcept(std::is_nothrow_move_constructible<T>::value&&
+ std::is_nothrow_move_assignable<T>::value) {
+ T tmp(std::move(l));
+ l = std::move(r);
+ r = std::move(tmp);
}
};
- template <class T>
- struct TSwapSelector<T, std::enable_if_t<THasSwap<T>::value>> {
- static inline void Swap(T& l, T& r) noexcept(noexcept(l.Swap(r))) {
- l.Swap(r);
+ template <class T>
+ struct TSwapSelector<T, std::enable_if_t<THasSwap<T>::value>> {
+ static inline void Swap(T& l, T& r) noexcept(noexcept(l.Swap(r))) {
+ l.Swap(r);
}
};
- template <class T>
- struct TSwapSelector<T, std::enable_if_t<THasswap<T>::value && !THasSwap<T>::value>> {
- static inline void Swap(T& l, T& r) noexcept(noexcept(l.swap(r))) {
- l.swap(r);
+ template <class T>
+ struct TSwapSelector<T, std::enable_if_t<THasswap<T>::value && !THasSwap<T>::value>> {
+ static inline void Swap(T& l, T& r) noexcept(noexcept(l.swap(r))) {
+ l.swap(r);
}
};
}
@@ -98,7 +98,7 @@ namespace NSwapCheck {
* DoSwap better than ::Swap in member functions...
*/
template <class T>
-static inline void DoSwap(T& l, T& r) noexcept(noexcept(NSwapCheck::TSwapSelector<T>::Swap(l, r))) {
+static inline void DoSwap(T& l, T& r) noexcept(noexcept(NSwapCheck::TSwapSelector<T>::Swap(l, r))) {
NSwapCheck::TSwapSelector<T>::Swap(l, r);
}
diff --git a/util/generic/variant.h b/util/generic/variant.h
index 9313f3cfa8..749fc75090 100644
--- a/util/generic/variant.h
+++ b/util/generic/variant.h
@@ -13,11 +13,11 @@ public:
v.valueless_by_exception() ? 0 : std::visit([](const auto& value) { return ComputeHash(value); }, v));
}
};
-
-template <>
+
+template <>
struct THash<std::monostate> {
-public:
+public:
constexpr size_t operator()(std::monostate) const noexcept {
return 1;
}
-};
+};
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp
index d805cffa1b..91da5cadca 100644
--- a/util/memory/blob.cpp
+++ b/util/memory/blob.cpp
@@ -77,11 +77,11 @@ public:
{
}
- TStringBlobBase(TString&& s) noexcept
- : S_(std::move(s))
- {
- }
-
+ TStringBlobBase(TString&& s) noexcept
+ : S_(std::move(s))
+ {
+ }
+
~TStringBlobBase() override = default;
void Ref() noexcept override {
@@ -390,10 +390,10 @@ TBlob TBlob::FromBuffer(TBuffer& in) {
return ConstructFromBuffer<TAtomicCounter>(in);
}
-template <class TCounter, class S>
-TBlob ConstructFromString(S&& s) {
+template <class TCounter, class S>
+TBlob ConstructFromString(S&& s) {
using TBase = TStringBlobBase<TCounter>;
- auto base = MakeHolder<TBase>(std::forward<S>(s));
+ auto base = MakeHolder<TBase>(std::forward<S>(s));
TBlob ret(base->String().data(), base->String().size(), base.Get());
Y_UNUSED(base.Release());
@@ -405,14 +405,14 @@ TBlob TBlob::FromStringSingleThreaded(const TString& s) {
return ConstructFromString<TSimpleCounter>(s);
}
-TBlob TBlob::FromStringSingleThreaded(TString&& s) {
- return ConstructFromString<TSimpleCounter>(std::move(s));
-}
-
+TBlob TBlob::FromStringSingleThreaded(TString&& s) {
+ return ConstructFromString<TSimpleCounter>(std::move(s));
+}
+
TBlob TBlob::FromString(const TString& s) {
return ConstructFromString<TAtomicCounter>(s);
}
-
-TBlob TBlob::FromString(TString&& s) {
- return ConstructFromString<TAtomicCounter>(std::move(s));
-}
+
+TBlob TBlob::FromString(TString&& s) {
+ return ConstructFromString<TAtomicCounter>(std::move(s));
+}
diff --git a/util/memory/blob.h b/util/memory/blob.h
index 73de03bb53..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -294,18 +294,18 @@ public:
/// @details The input object becomes empty.
static TBlob FromBuffer(TBuffer& in);
- /// Creates a blob from TString with a single-threaded (non atomic) refcounter.
+ /// Creates a blob from TString with a single-threaded (non atomic) refcounter.
static TBlob FromStringSingleThreaded(const TString& s);
- /// Creates a blob from TString with a single-threaded (non atomic) refcounter. Doesn't copy its content.
- static TBlob FromStringSingleThreaded(TString&& s);
-
- /// Creates a blob from TString with a multi-threaded (atomic) refcounter.
+ /// Creates a blob from TString with a single-threaded (non atomic) refcounter. Doesn't copy its content.
+ static TBlob FromStringSingleThreaded(TString&& s);
+
+ /// Creates a blob from TString with a multi-threaded (atomic) refcounter.
static TBlob FromString(const TString& s);
- /// Creates a blob from TString with a multi-threaded (atomic) refcounter. Doesn't copy its content.
- static TBlob FromString(TString&& s);
-
+ /// Creates a blob from TString with a multi-threaded (atomic) refcounter. Doesn't copy its content.
+ static TBlob FromString(TString&& s);
+
private:
inline void Ref() noexcept {
if (S_.Base) {
diff --git a/util/network/address.cpp b/util/network/address.cpp
index 2d632796f3..a81a9e6994 100644
--- a/util/network/address.cpp
+++ b/util/network/address.cpp
@@ -131,7 +131,7 @@ TString NAddr::PrintHostAndPort(const IRemoteAddr& addr) {
}
IRemoteAddrPtr NAddr::GetSockAddr(SOCKET s) {
- auto addr = MakeHolder<TOpaqueAddr>();
+ auto addr = MakeHolder<TOpaqueAddr>();
if (getsockname(s, addr->MutableAddr(), addr->LenPtr()) < 0) {
ythrow TSystemError() << "getsockname() failed";
diff --git a/util/network/address.h b/util/network/address.h
index 7d1d3f7b53..448fcac0c9 100644
--- a/util/network/address.h
+++ b/util/network/address.h
@@ -15,7 +15,7 @@ namespace NAddr {
virtual socklen_t Len() const = 0;
};
- using IRemoteAddrPtr = THolder<IRemoteAddr>;
+ using IRemoteAddrPtr = THolder<IRemoteAddr>;
using IRemoteAddrRef = TAtomicSharedPtr<NAddr::IRemoteAddr>;
IRemoteAddrPtr GetSockAddr(SOCKET s);
diff --git a/util/string/split.h b/util/string/split.h
index 14e93e89c2..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -264,18 +264,18 @@ namespace NSplitTargetHasPushBack {
Y_HAS_MEMBER(push_back, PushBack);
}
-template <class T, class = void>
-struct TConsumerBackInserter;
+template <class T, class = void>
+struct TConsumerBackInserter;
template <class T>
-struct TConsumerBackInserter<T, std::enable_if_t<NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
+struct TConsumerBackInserter<T, std::enable_if_t<NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
static void DoInsert(T* C, const typename T::value_type& i) {
C->push_back(i);
}
};
template <class T>
-struct TConsumerBackInserter<T, std::enable_if_t<!NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
+struct TConsumerBackInserter<T, std::enable_if_t<!NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
static void DoInsert(T* C, const typename T::value_type& i) {
C->insert(C->end(), i);
}
@@ -290,7 +290,7 @@ struct TContainerConsumer {
template <class I>
inline bool Consume(I* b, I* d, I* /*e*/) {
- TConsumerBackInserter<T>::DoInsert(C, typename T::value_type(b, d));
+ TConsumerBackInserter<T>::DoInsert(C, typename T::value_type(b, d));
return true;
}
@@ -307,7 +307,7 @@ struct TContainerConvertingConsumer {
template <class I>
inline bool Consume(I* b, I* d, I* /*e*/) {
- TConsumerBackInserter<T>::DoInsert(C, FromString<typename T::value_type>(TStringBuf(b, d)));
+ TConsumerBackInserter<T>::DoInsert(C, FromString<typename T::value_type>(TStringBuf(b, d)));
return true;
}
diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp
index 944a4c6e87..2506cb7a91 100644
--- a/util/system/event_ut.cpp
+++ b/util/system/event_ut.cpp
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
TManualEvent event[limit];
TThreadPool queue;
queue.Start(limit);
- TVector<THolder<IObjectInQueue>> tasks;
+ TVector<THolder<IObjectInQueue>> tasks;
for (size_t i = 0; i < limit; ++i) {
tasks.emplace_back(MakeHolder<TSignalTask>(event[i]));
UNIT_ASSERT(queue.Add(tasks.back().Get()));
@@ -115,16 +115,16 @@ Y_UNIT_TEST_SUITE(EventTest) {
/** Test for a problem: http://nga.at.yandex-team.ru/5772 */
Y_UNIT_TEST(DestructorBeforeSignalFinishTest) {
return;
- TVector<THolder<IObjectInQueue>> tasks;
+ TVector<THolder<IObjectInQueue>> tasks;
for (size_t i = 0; i < 1000; ++i) {
- auto owner = MakeHolder<TOwnerTask>();
+ auto owner = MakeHolder<TOwnerTask>();
tasks.emplace_back(MakeHolder<TSignalTask>(*owner->Ev));
- tasks.emplace_back(std::move(owner));
+ tasks.emplace_back(std::move(owner));
}
TThreadPool queue;
queue.Start(4);
- for (auto& task : tasks) {
+ for (auto& task : tasks) {
UNIT_ASSERT(queue.Add(task.Get()));
}
queue.Stop();
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index db4d894072..057a814f0a 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -57,7 +57,7 @@ namespace {
return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
}
- static inline THolder<TDynamicLibrary> OpenLibc() {
+ static inline THolder<TDynamicLibrary> OpenLibc() {
const char* libs[] = {
"/lib/libc.so.8",
"/lib/libc.so.7",
@@ -66,7 +66,7 @@ namespace {
for (auto& lib : libs) {
try {
- return MakeHolder<TDynamicLibrary>(lib);
+ return MakeHolder<TDynamicLibrary>(lib);
} catch (...) {
// ¯\_(ツ)_/¯
}
@@ -83,7 +83,7 @@ namespace {
return Lib.Get();
}
- THolder<TDynamicLibrary> Lib;
+ THolder<TDynamicLibrary> Lib;
TFunc Func;
};
diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp
index 722fd2237b..73f109dc88 100644
--- a/util/system/filemap_ut.cpp
+++ b/util/system/filemap_ut.cpp
@@ -164,10 +164,10 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
file.Close();
// Make 16 maps of our file, which would require 16*128M = 2Gb and exceed our 1Gb limit
- TVector<THolder<TFileMap>> maps;
+ TVector<THolder<TFileMap>> maps;
for (int i = 0; i < 16; ++i) {
- maps.emplace_back(MakeHolder<TFileMap>(FileName_, TMemoryMapCommon::oRdOnly | TMemoryMapCommon::oNotGreedy));
+ maps.emplace_back(MakeHolder<TFileMap>(FileName_, TMemoryMapCommon::oRdOnly | TMemoryMapCommon::oNotGreedy));
maps.back()->Map(i * sizeof(page), sizeof(page));
}
diff --git a/util/system/tls.cpp b/util/system/tls.cpp
index 4d06470b65..c2f1a04a14 100644
--- a/util/system/tls.cpp
+++ b/util/system/tls.cpp
@@ -208,7 +208,7 @@ namespace {
}
private:
- using TPTSRef = THolder<TPerThreadStorage>;
+ using TPTSRef = THolder<TPerThreadStorage>;
TMutex Lock_;
THashMap<TThread::TId, TPTSRef> Datas_;
};
diff --git a/util/system/tls.h b/util/system/tls.h
index c9ad6b4a71..3c4f56dbeb 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -61,7 +61,7 @@
//...later somewhere in cpp...
TMyWriter*& writerRef = ThreadLocalWriter.Get();
if (writerRef == nullptr) {
- THolder<TMyWriter> threadLocalWriter( new TMyWriter(
+ THolder<TMyWriter> threadLocalWriter( new TMyWriter(
*Session,
MinLogError,
MaxRps,
diff --git a/util/system/types.cpp b/util/system/types.cpp
index 2af2d90a48..11cc72aee3 100644
--- a/util/system/types.cpp
+++ b/util/system/types.cpp
@@ -15,4 +15,4 @@ static_assert(sizeof(i64) == 8, "incorrect i64 type");
static_assert(sizeof(size_t) == sizeof(ssize_t), "incorrect ssize_t");
-static_assert(TTypeList<ui32, ui64>::THave<size_t>::value, "incorrect size_t");
+static_assert(TTypeList<ui32, ui64>::THave<size_t>::value, "incorrect size_t");
diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp
index 50a51680e2..48e898f32d 100644
--- a/util/thread/factory.cpp
+++ b/util/thread/factory.cpp
@@ -66,8 +66,8 @@ namespace {
};
}
-THolder<IThread> IThreadFactory::Run(std::function<void()> func) {
- THolder<IThread> ret(DoCreate());
+THolder<IThread> IThreadFactory::Run(std::function<void()> func) {
+ THolder<IThread> ret(DoCreate());
ret->Run(new ::TThreadFactoryFuncObj(func));
diff --git a/util/thread/factory.h b/util/thread/factory.h
index 2330435d11..561fcbac88 100644
--- a/util/thread/factory.h
+++ b/util/thread/factory.h
@@ -47,15 +47,15 @@ public:
virtual ~IThreadFactory() = default;
// XXX: rename to Start
- inline THolder<IThread> Run(IThreadAble* func) {
- THolder<IThread> ret(DoCreate());
+ inline THolder<IThread> Run(IThreadAble* func) {
+ THolder<IThread> ret(DoCreate());
ret->Run(func);
return ret;
}
- THolder<IThread> Run(std::function<void()> func);
+ THolder<IThread> Run(std::function<void()> func);
private:
virtual IThread* DoCreate() = 0;
diff --git a/util/thread/factory_ut.cpp b/util/thread/factory_ut.cpp
index 352c7c90a6..647d96c901 100644
--- a/util/thread/factory_ut.cpp
+++ b/util/thread/factory_ut.cpp
@@ -29,7 +29,7 @@ private:
TRunAble r;
{
- THolder<IThreadFactory::IThread> thr = SystemThreadFactory()->Run(&r);
+ THolder<IThreadFactory::IThread> thr = SystemThreadFactory()->Run(&r);
thr->Join();
}
@@ -45,7 +45,7 @@ private:
pool.Start(0);
- THolder<IThreadFactory::IThread> thr = pool.Run(&r);
+ THolder<IThreadFactory::IThread> thr = pool.Run(&r);
thr->Join();
}
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h
index 647c03fb3c..ab523631e4 100644
--- a/util/thread/lfqueue.h
+++ b/util/thread/lfqueue.h
@@ -362,7 +362,7 @@ public:
template <class T, class TCounter>
class TAutoLockFreeQueue {
public:
- using TRef = THolder<T>;
+ using TRef = THolder<T>;
inline ~TAutoLockFreeQueue() {
TRef tmp;
diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp
index 6f99c21e59..05fad02e9b 100644
--- a/util/thread/pool.cpp
+++ b/util/thread/pool.cpp
@@ -68,7 +68,7 @@ TThreadFactoryHolder::TThreadFactoryHolder() noexcept
class TThreadPool::TImpl: public TIntrusiveListItem<TImpl>, public IThreadFactory::IThreadAble {
using TTsr = IThreadPool::TTsr;
using TJobQueue = TFastQueue<IObjectInQueue*>;
- using TThreadRef = THolder<IThreadFactory::IThread>;
+ using TThreadRef = THolder<IThreadFactory::IThread>;
public:
inline TImpl(TThreadPool* parent, size_t thrnum, size_t maxqueue, const TParams& params)
@@ -415,7 +415,7 @@ public:
private:
TImpl* Impl_;
- THolder<IThreadFactory::IThread> Thread_;
+ THolder<IThreadFactory::IThread> Thread_;
};
inline TImpl(TAdaptiveThreadPool* parent, const TParams& params)
@@ -647,8 +647,8 @@ namespace {
THolder<IObjectInQueue> Owned;
public:
- TOwnedObjectInQueue(THolder<IObjectInQueue> owned)
- : Owned(std::move(owned))
+ TOwnedObjectInQueue(THolder<IObjectInQueue> owned)
+ : Owned(std::move(owned))
{
}
@@ -663,12 +663,12 @@ void IThreadPool::SafeAdd(IObjectInQueue* obj) {
Y_ENSURE_EX(Add(obj), TThreadPoolException() << TStringBuf("can not add object to queue"));
}
-void IThreadPool::SafeAddAndOwn(THolder<IObjectInQueue> obj) {
+void IThreadPool::SafeAddAndOwn(THolder<IObjectInQueue> obj) {
Y_ENSURE_EX(AddAndOwn(std::move(obj)), TThreadPoolException() << TStringBuf("can not add to queue and own"));
}
-bool IThreadPool::AddAndOwn(THolder<IObjectInQueue> obj) {
- auto owner = MakeHolder<TOwnedObjectInQueue>(std::move(obj));
+bool IThreadPool::AddAndOwn(THolder<IObjectInQueue> obj) {
+ auto owner = MakeHolder<TOwnedObjectInQueue>(std::move(obj));
bool added = Add(owner.Get());
if (added) {
Y_UNUSED(owner.Release());
diff --git a/util/thread/pool.h b/util/thread/pool.h
index 84e6e694fb..d1ea3a67cb 100644
--- a/util/thread/pool.h
+++ b/util/thread/pool.h
@@ -153,7 +153,7 @@ public:
Y_ENSURE_EX(AddFunc(std::forward<T>(func)), TThreadPoolException() << TStringBuf("can not add function to queue"));
}
- void SafeAddAndOwn(THolder<IObjectInQueue> obj);
+ void SafeAddAndOwn(THolder<IObjectInQueue> obj);
/**
* Add object to queue, run ojb->Proccess in other threads.
@@ -173,7 +173,7 @@ public:
return added;
}
- bool AddAndOwn(THolder<IObjectInQueue> obj) Y_WARN_UNUSED_RESULT;
+ bool AddAndOwn(THolder<IObjectInQueue> obj) Y_WARN_UNUSED_RESULT;
virtual void Start(size_t threadCount, size_t queueSizeLimit = 0) = 0;
/** Wait for completion of all scheduled objects, and then exit */
virtual void Stop() noexcept = 0;
@@ -377,7 +377,7 @@ private:
TSlave* Slave_;
};
-inline void Delete(THolder<IThreadPool> q) {
+inline void Delete(THolder<IThreadPool> q) {
if (q.Get()) {
q->Stop();
}
diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp
index 0fa57af1d0..893770d0c4 100644
--- a/util/thread/pool_ut.cpp
+++ b/util/thread/pool_ut.cpp
@@ -24,7 +24,7 @@ struct TThreadPoolTest {
}
void Process(void*) override {
- THolder<TTask> This(this);
+ THolder<TTask> This(this);
TGuard<TSpinLock> guard(Test->Lock);
Test->R ^= Value;
diff --git a/util/ysaveload.h b/util/ysaveload.h
index 5527df5847..02efb4049b 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -5,7 +5,7 @@
#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
-#include <util/generic/algorithm.h>
+#include <util/generic/algorithm.h>
#include <util/stream/output.h>
#include <util/stream/input.h>
@@ -128,15 +128,15 @@ struct TSerializerTakingIntoAccountThePodType {
}
};
-namespace NHasSaveLoad {
- Y_HAS_MEMBER(SaveLoad);
-}
-
-template <class T, class = void>
-struct TSerializerMethodSelector;
-
-template <class T>
-struct TSerializerMethodSelector<T, std::enable_if_t<NHasSaveLoad::THasSaveLoad<T>::value>> {
+namespace NHasSaveLoad {
+ Y_HAS_MEMBER(SaveLoad);
+}
+
+template <class T, class = void>
+struct TSerializerMethodSelector;
+
+template <class T>
+struct TSerializerMethodSelector<T, std::enable_if_t<NHasSaveLoad::THasSaveLoad<T>::value>> {
static inline void Save(IOutputStream* out, const T& t) {
//assume Save clause do not change t
(const_cast<T&>(t)).SaveLoad(out);
@@ -153,7 +153,7 @@ struct TSerializerMethodSelector<T, std::enable_if_t<NHasSaveLoad::THasSaveLoad<
};
template <class T>
-struct TSerializerMethodSelector<T, std::enable_if_t<!NHasSaveLoad::THasSaveLoad<T>::value>> {
+struct TSerializerMethodSelector<T, std::enable_if_t<!NHasSaveLoad::THasSaveLoad<T>::value>> {
static inline void Save(IOutputStream* out, const T& t) {
t.Save(out);
}
@@ -420,24 +420,24 @@ public:
}
};
-template <class T>
+template <class T>
struct TTupleSerializer {
- template <class F, class Tuple, size_t... Indices>
- static inline void ReverseUseless(F&& f, Tuple&& t, std::index_sequence<Indices...>) {
- ApplyToMany(
- std::forward<F>(f),
- // We need to do this trick because we don't want to break backward compatibility.
- // Tuples are being packed in reverse order.
- std::get<std::tuple_size<T>::value - Indices - 1>(std::forward<Tuple>(t))...);
+ template <class F, class Tuple, size_t... Indices>
+ static inline void ReverseUseless(F&& f, Tuple&& t, std::index_sequence<Indices...>) {
+ ApplyToMany(
+ std::forward<F>(f),
+ // We need to do this trick because we don't want to break backward compatibility.
+ // Tuples are being packed in reverse order.
+ std::get<std::tuple_size<T>::value - Indices - 1>(std::forward<Tuple>(t))...);
}
- static inline void Save(IOutputStream* stream, const T& t) {
- ReverseUseless([&](const auto& v) { ::Save(stream, v); }, t,
+ static inline void Save(IOutputStream* stream, const T& t) {
+ ReverseUseless([&](const auto& v) { ::Save(stream, v); }, t,
std::make_index_sequence<std::tuple_size<T>::value>{});
}
- static inline void Load(IInputStream* stream, T& t) {
- ReverseUseless([&](auto& v) { ::Load(stream, v); }, t,
+ static inline void Load(IInputStream* stream, T& t) {
+ ReverseUseless([&](auto& v) { ::Load(stream, v); }, t,
std::make_index_sequence<std::tuple_size<T>::value>{});
}
};
@@ -641,15 +641,15 @@ public:
#ifndef __NVCC__
-namespace NPrivate {
- template <class Variant, class T, size_t I>
- void LoadVariantAlternative(IInputStream* is, Variant& v) {
- T loaded;
- ::Load(is, loaded);
- v.template emplace<I>(std::move(loaded));
- }
-}
-
+namespace NPrivate {
+ template <class Variant, class T, size_t I>
+ void LoadVariantAlternative(IInputStream* is, Variant& v) {
+ T loaded;
+ ::Load(is, loaded);
+ v.template emplace<I>(std::move(loaded));
+ }
+}
+
template <typename... Args>
struct TSerializer<std::variant<Args...>> {
using TVar = std::variant<Args...>;
@@ -664,21 +664,21 @@ struct TSerializer<std::variant<Args...>> {
}
static void Load(IInputStream* is, TVar& v) {
- ui8 index;
- ::Load(is, index);
+ ui8 index;
+ ::Load(is, index);
if (Y_UNLIKELY(index >= sizeof...(Args))) {
::NPrivate::ThrowUnexpectedVariantTagException(index);
- }
- LoadImpl(is, v, index, std::index_sequence_for<Args...>{});
+ }
+ LoadImpl(is, v, index, std::index_sequence_for<Args...>{});
}
-
-private:
- template <size_t... Is>
- static void LoadImpl(IInputStream* is, TVar& v, ui8 index, std::index_sequence<Is...>) {
+
+private:
+ template <size_t... Is>
+ static void LoadImpl(IInputStream* is, TVar& v, ui8 index, std::index_sequence<Is...>) {
using TLoader = void (*)(IInputStream*, TVar & v);
- constexpr TLoader loaders[] = {::NPrivate::LoadVariantAlternative<TVar, Args, Is>...};
- loaders[index](is, v);
- }
+ constexpr TLoader loaders[] = {::NPrivate::LoadVariantAlternative<TVar, Args, Is>...};
+ loaders[index](is, v);
+ }
};
#endif
@@ -693,14 +693,14 @@ static inline void SaveLoad(IInputStream* in, T& t) {
Load(in, t);
}
-template <class S, class... Ts>
-static inline void SaveMany(S* s, const Ts&... t) {
- ApplyToMany([&](const auto& v) { Save(s, v); }, t...);
+template <class S, class... Ts>
+static inline void SaveMany(S* s, const Ts&... t) {
+ ApplyToMany([&](const auto& v) { Save(s, v); }, t...);
}
-template <class S, class... Ts>
-static inline void LoadMany(S* s, Ts&... t) {
- ApplyToMany([&](auto& v) { Load(s, v); }, t...);
+template <class S, class... Ts>
+static inline void LoadMany(S* s, Ts&... t) {
+ ApplyToMany([&](auto& v) { Load(s, v); }, t...);
}
#define Y_SAVELOAD_DEFINE(...) \