aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorAndrey Khalyavin <halyavin@gmail.com>2022-02-10 16:46:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:30 +0300
commit4b839d0704ee9be1dabb0310a1f03af24963637b (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/generic
parentf773626848a7c7456803654292e716b83d69cc12 (diff)
downloadydb-4b839d0704ee9be1dabb0310a1f03af24963637b.tar.gz
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/algorithm_ut.cpp2
-rw-r--r--util/generic/bitmap.h4
-rw-r--r--util/generic/cast.h6
-rw-r--r--util/generic/fwd.h4
-rw-r--r--util/generic/hash.h8
-rw-r--r--util/generic/map.h4
-rw-r--r--util/generic/map_ut.cpp8
-rw-r--r--util/generic/maybe_traits.h2
-rw-r--r--util/generic/ptr.h4
-rw-r--r--util/generic/set_ut.cpp8
-rw-r--r--util/generic/typetraits.h2
-rw-r--r--util/generic/typetraits_ut.cpp162
-rw-r--r--util/generic/xrange.h30
-rw-r--r--util/generic/ymath.h52
-rw-r--r--util/generic/ymath_ut.cpp22
15 files changed, 159 insertions, 159 deletions
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 9d1942769d..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -845,6 +845,6 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(AccumulateWithBinOp) {
std::vector<int> v = {1, 2, 777};
- UNIT_ASSERT_VALUES_EQUAL(TString("begin;1;2;777"), Accumulate(v, TString("begin"), [](auto&& a, auto& b) { return a + ";" + ToString(b); }));
+ UNIT_ASSERT_VALUES_EQUAL(TString("begin;1;2;777"), Accumulate(v, TString("begin"), [](auto&& a, auto& b) { return a + ";" + ToString(b); }));
}
};
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index 8289cf18a8..f77d182460 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -315,7 +315,7 @@ public:
using TThis = TBitMapOps<TTraits>;
private:
- static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value");
+ static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value");
static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
@@ -567,7 +567,7 @@ public:
template <class TTo>
void Export(size_t pos, TTo& to) const {
- static_assert(std::is_unsigned<TTo>::value, "expect std::is_unsigned<TTo>::value");
+ static_assert(std::is_unsigned<TTo>::value, "expect std::is_unsigned<TTo>::value");
to = 0;
size_t chunkpos = pos >> DivCount;
if (chunkpos >= Mask.GetChunkCapacity())
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 69bfdf4102..0d4a41f385 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -84,7 +84,7 @@ public:
template <class TType>
constexpr bool IsNegative(const TType value) noexcept {
- return TInteger<std::is_unsigned<TType>::value>::IsNegative(value);
+ return TInteger<std::is_unsigned<TType>::value>::IsNegative(value);
}
namespace NPrivate {
@@ -116,7 +116,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
using TSmallInt = ::NPrivate::TUnderlyingTypeOrSelf<TSmall>;
using TLargeInt = ::NPrivate::TUnderlyingTypeOrSelf<TLarge>;
- if (std::is_unsigned<TSmallInt>::value && std::is_signed<TLargeInt>::value) {
+ if (std::is_unsigned<TSmallInt>::value && std::is_signed<TLargeInt>::value) {
if (IsNegative(largeInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
<< TypeName<TSmallInt>()
@@ -126,7 +126,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
TSmallInt smallInt = TSmallInt(largeInt);
- if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
+ if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
if (IsNegative(smallInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
<< TypeName<TSmallInt>()
diff --git a/util/generic/fwd.h b/util/generic/fwd.h
index ab350d1abc..5cc2da40e5 100644
--- a/util/generic/fwd.h
+++ b/util/generic/fwd.h
@@ -64,10 +64,10 @@ class TQueue;
template <class T, class S = TVector<T>, class C = TLess<T>>
class TPriorityQueue;
-template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
+template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
class THashMap;
-template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
+template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
class THashMultiMap;
template <class Value, class HashFcn = THash<Value>, class EqualKey = TEqualTo<Value>, class Alloc = std::allocator<Value>>
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 8790b15e1a..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -3,7 +3,7 @@
#include "fwd.h"
#include "mapfindptr.h"
-#include <util/memory/alloc.h>
+#include <util/memory/alloc.h>
#include <util/system/type_name.h>
#include <util/system/yassert.h>
#include <util/str_stl.h>
@@ -347,7 +347,7 @@ private:
* Note that there are no specializations for the case when only one or two
* of the functors are empty as this is a case that's just way too rare.
*/
-template <class HashFcn, class ExtractKey, class EqualKey, class Alloc, bool IsEmpty = std::is_empty<HashFcn>::value&& std::is_empty<ExtractKey>::value&& std::is_empty<EqualKey>::value>
+template <class HashFcn, class ExtractKey, class EqualKey, class Alloc, bool IsEmpty = std::is_empty<HashFcn>::value&& std::is_empty<ExtractKey>::value&& std::is_empty<EqualKey>::value>
class _yhashtable_base: public _allocator_base<Alloc> {
using base_type = _allocator_base<Alloc>;
@@ -440,8 +440,8 @@ template <class Value, class Key, class HashFcn, class ExtractKey, class EqualKe
struct _yhashtable_traits {
using node = __yhashtable_node<Value>;
- using node_allocator_type = TReboundAllocator<Alloc, node>;
- using nodep_allocator_type = TReboundAllocator<Alloc, node*>;
+ using node_allocator_type = TReboundAllocator<Alloc, node>;
+ using nodep_allocator_type = TReboundAllocator<Alloc, node*>;
using base_type = _yhashtable_base<HashFcn, ExtractKey, EqualKey, node_allocator_type>;
};
diff --git a/util/generic/map.h b/util/generic/map.h
index a43c8eca4e..b5001b56c0 100644
--- a/util/generic/map.h
+++ b/util/generic/map.h
@@ -13,7 +13,7 @@
template <class K, class V, class Less, class A>
class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>, public TMapOps<TMap<K, V, Less, A>> {
- using TBase = std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
+ using TBase = std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
public:
using TBase::TBase;
@@ -29,7 +29,7 @@ public:
template <class K, class V, class Less, class A>
class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> {
- using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
+ using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
public:
using TBase::TBase;
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index d82db9a4f8..79e832b024 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -254,8 +254,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
bool operator()(int lhs, TKey rhs) const {
return lhs < rhs.m_data;
}
-
- using is_transparent = void;
+
+ using is_transparent = void;
};
struct TKeyCmpPtr {
@@ -270,8 +270,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
bool operator()(int lhs, TKey const volatile* rhs) const {
return lhs < (*rhs).m_data;
}
-
- using is_transparent = void;
+
+ using is_transparent = void;
};
Y_UNIT_TEST(TestTemplateMethods) {
diff --git a/util/generic/maybe_traits.h b/util/generic/maybe_traits.h
index 808e597971..9e9f56955e 100644
--- a/util/generic/maybe_traits.h
+++ b/util/generic/maybe_traits.h
@@ -1,6 +1,6 @@
#pragma once
-#include <memory>
+#include <memory>
#include <type_traits>
#include <initializer_list>
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 22f22787ba..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -1080,7 +1080,7 @@ public:
return T_.Get();
}
- inline T* Mutable() {
+ inline T* Mutable() {
Unshare();
return T_.Get();
@@ -1109,7 +1109,7 @@ public:
}
#endif
private:
- inline void Unshare() {
+ inline void Unshare() {
if (Shared()) {
Reset(TCopy::Copy(T_.Get()));
}
diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp
index 5fd8505a71..d2769d327f 100644
--- a/util/generic/set_ut.cpp
+++ b/util/generic/set_ut.cpp
@@ -289,8 +289,8 @@ Y_UNIT_TEST_SUITE(YSetTest) {
bool operator()(int lhs, TKey rhs) const {
return lhs < rhs.m_data;
}
-
- using is_transparent = void;
+
+ using is_transparent = void;
};
struct TKeyCmpPtr {
@@ -305,8 +305,8 @@ Y_UNIT_TEST_SUITE(YSetTest) {
bool operator()(int lhs, TKey const volatile* rhs) const {
return lhs < (*rhs).m_data;
}
-
- using is_transparent = void;
+
+ using is_transparent = void;
};
Y_UNIT_TEST(TestTemplateMethods) {
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index b8a4db5376..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -111,7 +111,7 @@ class TTypeTraits: public TTypeTraitsBase<T> {
std::false_type,
::NPrivate::TIsSmall<T>>::value);
-public:
+public:
/*
* can be used in function templates for effective parameters passing
*/
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index ad566702f2..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -85,15 +85,15 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
}
Y_UNIT_TEST(TestRemoveReference) {
- ASSERT_SAME_TYPE(std::remove_reference_t<int>, int);
- ASSERT_SAME_TYPE(std::remove_reference_t<const int>, const int);
- ASSERT_SAME_TYPE(std::remove_reference_t<int&>, int);
- ASSERT_SAME_TYPE(std::remove_reference_t<const int&>, const int);
- ASSERT_SAME_TYPE(std::remove_reference_t<int&&>, int);
- ASSERT_SAME_TYPE(std::remove_reference_t<const int&&>, const int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<int>, int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<const int>, const int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<int&>, int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<const int&>, const int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<int&&>, int);
+ ASSERT_SAME_TYPE(std::remove_reference_t<const int&&>, const int);
class TIncompleteType;
- ASSERT_SAME_TYPE(std::remove_reference_t<TIncompleteType&>, TIncompleteType);
+ ASSERT_SAME_TYPE(std::remove_reference_t<TIncompleteType&>, TIncompleteType);
}
Y_UNIT_TEST(TestRemoveConst) {
@@ -114,22 +114,22 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
Y_UNIT_TEST(TestClass) {
UNIT_ASSERT(std::is_class<TString>::value);
- UNIT_ASSERT(!std::is_class<ETestEnum>::value);
- UNIT_ASSERT(!std::is_class<int>::value);
- UNIT_ASSERT(!std::is_class<void*>::value);
+ UNIT_ASSERT(!std::is_class<ETestEnum>::value);
+ UNIT_ASSERT(!std::is_class<int>::value);
+ UNIT_ASSERT(!std::is_class<void*>::value);
}
template <class T>
inline void TestArithmeticType() {
- UNIT_ASSERT(std::is_arithmetic<T>::value);
- UNIT_ASSERT(std::is_arithmetic<const T>::value);
- UNIT_ASSERT(std::is_arithmetic<volatile T>::value);
- UNIT_ASSERT(std::is_arithmetic<const volatile T>::value);
-
- UNIT_ASSERT(!std::is_arithmetic<T&>::value);
- UNIT_ASSERT(!std::is_arithmetic<T&&>::value);
- UNIT_ASSERT(!std::is_arithmetic<T*>::value);
-
+ UNIT_ASSERT(std::is_arithmetic<T>::value);
+ UNIT_ASSERT(std::is_arithmetic<const T>::value);
+ UNIT_ASSERT(std::is_arithmetic<volatile T>::value);
+ UNIT_ASSERT(std::is_arithmetic<const volatile T>::value);
+
+ UNIT_ASSERT(!std::is_arithmetic<T&>::value);
+ UNIT_ASSERT(!std::is_arithmetic<T&&>::value);
+ UNIT_ASSERT(!std::is_arithmetic<T*>::value);
+
bool a;
a = std::is_same<typename TTypeTraits<T>::TFuncParam, T>::value;
@@ -138,56 +138,56 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
UNIT_ASSERT(a);
}
- template <class T>
- inline void TestUnsignedIntType() {
- UNIT_ASSERT(std::is_unsigned<T>::value);
- UNIT_ASSERT(std::is_unsigned<const T>::value);
- UNIT_ASSERT(std::is_unsigned<volatile T>::value);
- UNIT_ASSERT(std::is_unsigned<const volatile T>::value);
-
- UNIT_ASSERT(!std::is_unsigned<T&>::value);
- UNIT_ASSERT(!std::is_unsigned<T&&>::value);
- UNIT_ASSERT(!std::is_unsigned<T*>::value);
-
+ template <class T>
+ inline void TestUnsignedIntType() {
+ UNIT_ASSERT(std::is_unsigned<T>::value);
+ UNIT_ASSERT(std::is_unsigned<const T>::value);
+ UNIT_ASSERT(std::is_unsigned<volatile T>::value);
+ UNIT_ASSERT(std::is_unsigned<const volatile T>::value);
+
+ UNIT_ASSERT(!std::is_unsigned<T&>::value);
+ UNIT_ASSERT(!std::is_unsigned<T&&>::value);
+ UNIT_ASSERT(!std::is_unsigned<T*>::value);
+
enum ETypedEnum: T {};
- UNIT_ASSERT(!std::is_unsigned<ETypedEnum>::value);
- }
-
- template <class T>
- inline void TestSignedIntType() {
- UNIT_ASSERT(std::is_signed<T>::value);
- UNIT_ASSERT(std::is_signed<const T>::value);
- UNIT_ASSERT(std::is_signed<volatile T>::value);
- UNIT_ASSERT(std::is_signed<const volatile T>::value);
-
- UNIT_ASSERT(!std::is_signed<T&>::value);
- UNIT_ASSERT(!std::is_signed<T&&>::value);
- UNIT_ASSERT(!std::is_signed<T*>::value);
-
+ UNIT_ASSERT(!std::is_unsigned<ETypedEnum>::value);
+ }
+
+ template <class T>
+ inline void TestSignedIntType() {
+ UNIT_ASSERT(std::is_signed<T>::value);
+ UNIT_ASSERT(std::is_signed<const T>::value);
+ UNIT_ASSERT(std::is_signed<volatile T>::value);
+ UNIT_ASSERT(std::is_signed<const volatile T>::value);
+
+ UNIT_ASSERT(!std::is_signed<T&>::value);
+ UNIT_ASSERT(!std::is_signed<T&&>::value);
+ UNIT_ASSERT(!std::is_signed<T*>::value);
+
enum ETypedEnum: T {};
- UNIT_ASSERT(!std::is_signed<ETypedEnum>::value);
- }
-
+ UNIT_ASSERT(!std::is_signed<ETypedEnum>::value);
+ }
+
Y_UNIT_TEST(TestBool) {
- TestArithmeticType<bool>();
- TestUnsignedIntType<bool>();
- }
-
+ TestArithmeticType<bool>();
+ TestUnsignedIntType<bool>();
+ }
+
Y_UNIT_TEST(TestUnsignedChar) {
TestArithmeticType<unsigned char>();
- TestUnsignedIntType<unsigned char>();
+ TestUnsignedIntType<unsigned char>();
}
Y_UNIT_TEST(TestSizeT) {
TestArithmeticType<size_t>();
- TestUnsignedIntType<size_t>();
+ TestUnsignedIntType<size_t>();
}
Y_UNIT_TEST(TestInt) {
- TestArithmeticType<int>();
- TestSignedIntType<int>();
- }
-
+ TestArithmeticType<int>();
+ TestSignedIntType<int>();
+ }
+
Y_UNIT_TEST(TestDouble) {
TestArithmeticType<double>();
}
@@ -206,25 +206,25 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
}
Y_UNIT_TEST(TestIsEmpty) {
- UNIT_ASSERT(std::is_empty<TEmptyClass>::value);
- UNIT_ASSERT(std::is_empty<TEmptyDerivedClass>::value);
- UNIT_ASSERT(std::is_empty<TAnotherEmptyClass>::value);
+ UNIT_ASSERT(std::is_empty<TEmptyClass>::value);
+ UNIT_ASSERT(std::is_empty<TEmptyDerivedClass>::value);
+ UNIT_ASSERT(std::is_empty<TAnotherEmptyClass>::value);
#ifdef _MSC_VER
UNIT_ASSERT(!std::is_empty<TEmptyMultiDerivedClass>::value);
#else
- UNIT_ASSERT(std::is_empty<TEmptyMultiDerivedClass>::value);
+ UNIT_ASSERT(std::is_empty<TEmptyMultiDerivedClass>::value);
#endif
- UNIT_ASSERT(!std::is_empty<TNonEmptyClass>::value);
- UNIT_ASSERT(!std::is_empty<TNonEmptyDerivedClass>::value);
+ UNIT_ASSERT(!std::is_empty<TNonEmptyClass>::value);
+ UNIT_ASSERT(!std::is_empty<TNonEmptyDerivedClass>::value);
}
Y_UNIT_TEST(TestIsStandardLayout) {
- UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass1>::value);
- UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass2>::value);
- UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass1>::value);
- UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass2>::value);
- UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass3>::value);
- UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass4>::value);
+ UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass1>::value);
+ UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass2>::value);
+ UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass1>::value);
+ UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass2>::value);
+ UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass3>::value);
+ UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass4>::value);
}
template <class T>
@@ -385,18 +385,18 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) {
template <typename T>
void TestImpl() {
//UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPod, TTypeTraits<T>::IsPod);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsVoid, std::is_void<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsEnum, std::is_enum<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsIntegral, std::is_integral<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsArithmetic, std::is_arithmetic<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsVolatile, std::is_volatile<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsConstant, std::is_const<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPointer, std::is_pointer<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsReference, std::is_reference<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsLvalueReference, std::is_lvalue_reference<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsRvalueReference, std::is_rvalue_reference<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsArray, std::is_array<T>::value);
- UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsClassType, std::is_class<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsVoid, std::is_void<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsEnum, std::is_enum<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsIntegral, std::is_integral<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsArithmetic, std::is_arithmetic<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsVolatile, std::is_volatile<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsConstant, std::is_const<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPointer, std::is_pointer<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsReference, std::is_reference<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsLvalueReference, std::is_lvalue_reference<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsRvalueReference, std::is_rvalue_reference<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsArray, std::is_array<T>::value);
+ UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsClassType, std::is_class<T>::value);
}
#define TYPE_TEST(name, type) \
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 6478b1cd22..5fc8c82912 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -30,14 +30,14 @@ namespace NPrivate {
{
}
- class TIterator {
+ class TIterator {
public:
- using value_type = T;
- using difference_type = TDiff;
- using pointer = const T*;
- using reference = const T&;
- using iterator_category = std::random_access_iterator_tag;
-
+ using value_type = T;
+ using difference_type = TDiff;
+ using pointer = const T*;
+ using reference = const T&;
+ using iterator_category = std::random_access_iterator_tag;
+
constexpr TIterator(T value) noexcept
: Value(value)
{
@@ -135,17 +135,17 @@ namespace NPrivate {
, Step_(step)
, Finish_(CalcRealFinish(Start_, finish, Step_))
{
- static_assert(std::is_integral<T>::value || std::is_pointer<T>::value, "T should be integral type or pointer");
+ static_assert(std::is_integral<T>::value || std::is_pointer<T>::value, "T should be integral type or pointer");
}
- class TIterator {
+ class TIterator {
public:
- using value_type = T;
- using difference_type = TDiff;
- using pointer = const T*;
- using reference = const T&;
- using iterator_category = std::random_access_iterator_tag;
-
+ using value_type = T;
+ using difference_type = TDiff;
+ using pointer = const T*;
+ using reference = const T&;
+ using iterator_category = std::random_access_iterator_tag;
+
constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
: Value_(value)
, Parent_(&parent)
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 0614b1d080..9ff9ae2abe 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#include <util/system/defaults.h>
#include <cmath>
@@ -120,32 +120,32 @@ inline double LogGamma(double x) noexcept {
return LogGammaImpl(x);
#endif
}
-
-/**
- * @returns x^n for integer n, n >= 0.
- */
+
+/**
+ * @returns x^n for integer n, n >= 0.
+ */
template <class T, class Int>
-T Power(T x, Int n) {
- static_assert(std::is_integral<Int>::value, "only integer powers are supported");
- Y_ASSERT(n >= 0);
- if (n == 0) {
- return T(1);
- }
- while ((n & 1) == 0) {
- x = x * x;
- n >>= 1;
- }
- T result = x;
- n >>= 1;
- while (n > 0) {
- x = x * x;
- if (n & 1) {
- result = result * x;
- }
- n >>= 1;
- }
- return result;
-};
+T Power(T x, Int n) {
+ static_assert(std::is_integral<Int>::value, "only integer powers are supported");
+ Y_ASSERT(n >= 0);
+ if (n == 0) {
+ return T(1);
+ }
+ while ((n & 1) == 0) {
+ x = x * x;
+ n >>= 1;
+ }
+ T result = x;
+ n >>= 1;
+ while (n > 0) {
+ x = x * x;
+ if (n & 1) {
+ result = result * x;
+ }
+ n >>= 1;
+ }
+ return result;
+};
/**
* Compares two floating point values and returns true if they are considered equal.
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 218801d1e6..29190b55eb 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -32,7 +32,7 @@ class TMathTest: public TTestBase {
UNIT_TEST(TestLogGamma);
UNIT_TEST(TestIsValidFloat);
UNIT_TEST(TestAbs);
- UNIT_TEST(TestPower);
+ UNIT_TEST(TestPower);
UNIT_TEST(TestSigmoid);
UNIT_TEST(TestCeilDiv);
UNIT_TEST_SUITE_END();
@@ -43,7 +43,7 @@ private:
void TestErf();
void TestLogGamma();
void TestAbs();
- void TestPower();
+ void TestPower();
void TestSigmoid();
void TestCeilDiv();
@@ -172,15 +172,15 @@ void TMathTest::TestAbs() {
UNIT_ASSERT_VALUES_EQUAL(Abs(-1.0), 1.0);
UNIT_ASSERT_VALUES_EQUAL(Abs(0.0), 0.0);
}
-
-void TMathTest::TestPower() {
- UNIT_ASSERT_VALUES_EQUAL(Power(0, 0), 1);
- UNIT_ASSERT_VALUES_EQUAL(Power(-1, 1), -1);
- UNIT_ASSERT_VALUES_EQUAL(Power(-1, 2), 1);
- UNIT_ASSERT_VALUES_EQUAL(Power(2LL, 32), 1LL << 32);
- UNIT_ASSERT_DOUBLES_EQUAL(Power(0.0, 0), 1.0, 1e-9);
- UNIT_ASSERT_DOUBLES_EQUAL(Power(0.1, 3), 1e-3, 1e-9);
-}
+
+void TMathTest::TestPower() {
+ UNIT_ASSERT_VALUES_EQUAL(Power(0, 0), 1);
+ UNIT_ASSERT_VALUES_EQUAL(Power(-1, 1), -1);
+ UNIT_ASSERT_VALUES_EQUAL(Power(-1, 2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(Power(2LL, 32), 1LL << 32);
+ UNIT_ASSERT_DOUBLES_EQUAL(Power(0.0, 0), 1.0, 1e-9);
+ UNIT_ASSERT_DOUBLES_EQUAL(Power(0.1, 3), 1e-3, 1e-9);
+}
void TMathTest::TestSigmoid() {
UNIT_ASSERT_EQUAL(Sigmoid(0.f), 0.5f);