diff options
author | iroubin <iroubin@yandex-team.ru> | 2022-02-10 16:52:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:52:05 +0300 |
commit | e1eef5fd2ea964227b9be2c182415857c35e1290 (patch) | |
tree | ab7fbbf3253d4c0e2793218f09378908beb025fb /util/generic | |
parent | 94a4c65975048c0c31313b5105d9eb14cbde4985 (diff) | |
download | ydb-e1eef5fd2ea964227b9be2c182415857c35e1290.tar.gz |
Restoring authorship annotation for <iroubin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/deque_ut.cpp | 64 | ||||
-rw-r--r-- | util/generic/hash.h | 8 | ||||
-rw-r--r-- | util/generic/hash_set.h | 4 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 250 | ||||
-rw-r--r-- | util/generic/ptr.h | 8 | ||||
-rw-r--r-- | util/generic/queue_ut.cpp | 112 | ||||
-rw-r--r-- | util/generic/set_ut.cpp | 40 | ||||
-rw-r--r-- | util/generic/typetraits_ut.cpp | 30 | ||||
-rw-r--r-- | util/generic/vector.h | 18 | ||||
-rw-r--r-- | util/generic/vector_ut.cpp | 20 |
10 files changed, 277 insertions, 277 deletions
diff --git a/util/generic/deque_ut.cpp b/util/generic/deque_ut.cpp index b363bfa361..93bf50fa92 100644 --- a/util/generic/deque_ut.cpp +++ b/util/generic/deque_ut.cpp @@ -26,45 +26,45 @@ protected: UNIT_TEST_SUITE_REGISTRATION(TDequeTest); -void TDequeTest::TestConstructorsAndAssignments() { +void TDequeTest::TestConstructorsAndAssignments() { using container = TDeque<int>; - - container c1; - c1.push_back(100); - c1.push_back(200); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(100, c1.at(0)); - UNIT_ASSERT_VALUES_EQUAL(200, c2.at(1)); - + + container c1; + c1.push_back(100); + c1.push_back(200); + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(100, c1.at(0)); + UNIT_ASSERT_VALUES_EQUAL(200, c2.at(1)); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(100, c3.at(0)); - - c2.push_back(300); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(300, c3.at(2)); - - c2.push_back(400); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(100, c3.at(0)); + + c2.push_back(300); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(300, c3.at(2)); + + c2.push_back(400); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(400, c3.at(3)); + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(400, c3.at(3)); int array[] = {2, 3, 4}; container c4 = {2, 3, 4}; UNIT_ASSERT_VALUES_EQUAL(c4, container(std::begin(array), std::end(array))); -} - +} + void TDequeTest::TestDeque1() { TDeque<int> d; UNIT_ASSERT(!d); diff --git a/util/generic/hash.h b/util/generic/hash.h index 154e424b44..e46db21fa9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -596,13 +596,13 @@ public: deinitialize_buckets(buckets); initialize_buckets_dynamic(buckets, ht.buckets.ExtSize()); } - + copy_from_dynamic(ht); } } return *this; } - + THashTable& operator=(THashTable&& ht) noexcept { basic_clear(); swap(ht); @@ -1519,7 +1519,7 @@ public: // THashMap has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp - + public: size_type size() const noexcept { return rep.size(); @@ -1844,7 +1844,7 @@ public: // THashMultiMap has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp - + public: size_type size() const { return rep.size(); diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index b19f6e8aee..e8088cf23b 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -114,7 +114,7 @@ public: // THashSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp - + public: size_type size() const { return rep.size(); @@ -363,7 +363,7 @@ public: // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp - + public: size_type size() const { return rep.size(); diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 6bfd815d0f..0551d58770 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -114,39 +114,39 @@ protected: UNIT_TEST_SUITE_REGISTRATION(THashTest); -void THashTest::TestHMapConstructorsAndAssignments() { +void THashTest::TestHMapConstructorsAndAssignments() { using container = THashMap<TString, int>; - - container c1; - c1["one"] = 1; - c1["two"] = 2; - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + + container c1; + c1["one"] = 1; + c1["two"] = 2; + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); UNIT_ASSERT_VALUES_EQUAL(1, c1.at("one")); /* Note: fails under MSVC since it does not support implicit generation of move constructors. */ - UNIT_ASSERT_VALUES_EQUAL(2, c2.at("two")); - + UNIT_ASSERT_VALUES_EQUAL(2, c2.at("two")); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(1, c3.at("one")); - - c2["three"] = 3; - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.at("three")); - - c2["four"] = 4; + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(1, c3.at("one")); + + c2["three"] = 3; + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.at("three")); + + c2["four"] = 4; c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.at("four")); + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.at("four")); const container c4{ {"one", 1}, @@ -163,8 +163,8 @@ void THashTest::TestHMapConstructorsAndAssignments() { // non-existent values must be zero-initialized UNIT_ASSERT_VALUES_EQUAL(c1["nonexistent"], 0); -} - +} + void THashTest::TestHMap1() { using maptype = THashMap<char, TString, THash<char>, TEqualTo<char>>; maptype m; @@ -260,36 +260,36 @@ void THashTest::TestHMMapEqualityOperator() { UNIT_ASSERT(c3 != base); } -void THashTest::TestHMMapConstructorsAndAssignments() { +void THashTest::TestHMMapConstructorsAndAssignments() { using container = THashMultiMap<TString, int>; - - container c1; - c1.insert(container::value_type("one", 1)); - c1.insert(container::value_type("two", 2)); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - + + container c1; + c1.insert(container::value_type("one", 1)); + c1.insert(container::value_type("two", 2)); + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - - c2.insert(container::value_type("three", 3)); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - - c2.insert(container::value_type("four", 4)); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + + c2.insert(container::value_type("three", 3)); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + + c2.insert(container::value_type("four", 4)); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); -} - + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); +} + void THashTest::TestHMMap1() { using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>; mmap m; @@ -366,38 +366,38 @@ void THashTest::TestHMMapHas() { UNIT_ASSERT(!m.contains('Z')); } -void THashTest::TestHSetConstructorsAndAssignments() { +void THashTest::TestHSetConstructorsAndAssignments() { using container = THashSet<int>; - - container c1; - c1.insert(100); - c1.insert(200); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + + container c1; + c1.insert(100); + c1.insert(200); + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); UNIT_ASSERT(c1.contains(100)); UNIT_ASSERT(c2.contains(200)); - + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); UNIT_ASSERT(c3.contains(100)); - - c2.insert(300); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + + c2.insert(300); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); UNIT_ASSERT(c3.contains(300)); - - c2.insert(400); + + c2.insert(400); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT(c3.contains(400)); container c4 = {1, 2, 3}; @@ -405,8 +405,8 @@ void THashTest::TestHSetConstructorsAndAssignments() { UNIT_ASSERT(c4.contains(1)); UNIT_ASSERT(c4.contains(2)); UNIT_ASSERT(c4.contains(3)); -} - +} + void THashTest::TestHSetSize() { using container = THashSet<int>; @@ -421,16 +421,16 @@ void THashTest::TestHSetSize() { UNIT_ASSERT_VALUES_EQUAL(2, c.size()); } -void THashTest::TestHSet2() { +void THashTest::TestHSet2() { THashSet<int, THash<int>, TEqualTo<int>> s; auto p = s.insert(42); - UNIT_ASSERT(p.second); - UNIT_ASSERT(*(p.first) == 42); - - p = s.insert(42); - UNIT_ASSERT(!p.second); -} - + UNIT_ASSERT(p.second); + UNIT_ASSERT(*(p.first) == 42); + + p = s.insert(42); + UNIT_ASSERT(!p.second); +} + void THashTest::TestHSetEqualityOperator() { using container = THashSet<int>; @@ -457,41 +457,41 @@ void THashTest::TestHSetEqualityOperator() { UNIT_ASSERT(c3 != base); } -void THashTest::TestHMSetConstructorsAndAssignments() { +void THashTest::TestHMSetConstructorsAndAssignments() { using container = THashMultiSet<int>; - - container c1; - c1.insert(100); - c1.insert(200); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - UNIT_ASSERT(c1.find(100) != c1.end()); - UNIT_ASSERT(c2.find(200) != c2.end()); - + + container c1; + c1.insert(100); + c1.insert(200); + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + UNIT_ASSERT(c1.find(100) != c1.end()); + UNIT_ASSERT(c2.find(200) != c2.end()); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - UNIT_ASSERT(c3.find(100) != c3.end()); - - c2.insert(300); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - UNIT_ASSERT(c3.find(300) != c3.end()); - - c2.insert(400); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + UNIT_ASSERT(c3.find(100) != c3.end()); + + c2.insert(300); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + UNIT_ASSERT(c3.find(300) != c3.end()); + + c2.insert(400); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - UNIT_ASSERT(c3.find(400) != c3.end()); -} - + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + UNIT_ASSERT(c3.find(400) != c3.end()); +} + void THashTest::TestHMSetSize() { using container = THashMultiSet<int>; diff --git a/util/generic/ptr.h b/util/generic/ptr.h index bd173b6a0e..19db0e3ec5 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -940,12 +940,12 @@ struct THash<TSharedPtr<T, C, D>>: THash<const T*> { } }; -template <class T, class D = TDelete> -using TAtomicSharedPtr = TSharedPtr<T, TAtomicCounter, D>; +template <class T, class D = TDelete> +using TAtomicSharedPtr = TSharedPtr<T, TAtomicCounter, D>; // use with great care. if in doubt, use TAtomicSharedPtr instead -template <class T, class D = TDelete> -using TSimpleSharedPtr = TSharedPtr<T, TSimpleCounter, D>; +template <class T, class D = TDelete> +using TSimpleSharedPtr = TSharedPtr<T, TSimpleCounter, D>; template <typename T, typename C, typename... Args> [[nodiscard]] TSharedPtr<T, C> MakeShared(Args&&... args) { diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp index c23e6acbee..a33399e104 100644 --- a/util/generic/queue_ut.cpp +++ b/util/generic/queue_ut.cpp @@ -5,74 +5,74 @@ #include <library/cpp/testing/unittest/registar.h> #include <utility> - + Y_UNIT_TEST_SUITE(TYQueueTest) { Y_UNIT_TEST(ConstructorsAndAssignments) { - { + { using container = TQueue<int>; - - container c1; + + container c1; UNIT_ASSERT(!c1); - c1.push(100); - c1.push(200); + c1.push(100); + c1.push(200); UNIT_ASSERT(c1); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - - c2.push(300); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - - c2.push(400); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + + c2.push(300); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + + c2.push(400); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - } - - { + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + } + + { using container = TPriorityQueue<int>; - - container c1; + + container c1; UNIT_ASSERT(!c1); - c1.push(100); - c1.push(200); + c1.push(100); + c1.push(200); UNIT_ASSERT(c1); - - container c2(c1); - - UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - + + container c2(c1); + + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); + container c3(std::move(c1)); - - UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); - UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - - c2.push(300); - c3 = c2; - - UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - - c2.push(400); + + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); + UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); + + c2.push(300); + c3 = c2; + + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); + + c2.push(400); c3 = std::move(c2); - - UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); - UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - } - } - + + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); + UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); + } + } + Y_UNIT_TEST(pqueue1) { TPriorityQueue<int, TDeque<int>, TLess<int>> q; diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp index c59ab6760b..d2769d327f 100644 --- a/util/generic/set_ut.cpp +++ b/util/generic/set_ut.cpp @@ -198,71 +198,71 @@ Y_UNIT_TEST_SUITE(YSetTest) { container c1; c1.insert(100); c1.insert(200); - + container c2(c1); - + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); UNIT_ASSERT(c1.contains(100)); UNIT_ASSERT(c2.contains(200)); - + container c3(std::move(c1)); - + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); UNIT_ASSERT(c3.contains(100)); - + c2.insert(300); c3 = c2; - + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); UNIT_ASSERT(c3.contains(300)); - + c2.insert(400); c3 = std::move(c2); - + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT(c3.contains(400)); } - + { using container = TMultiSet<int>; - + container c1; c1.insert(100); c1.insert(200); - + container c2(c1); - + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); UNIT_ASSERT(c1.find(100) != c1.end()); UNIT_ASSERT(c2.find(200) != c2.end()); - + container c3(std::move(c1)); - + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); UNIT_ASSERT(c3.find(100) != c3.end()); - + c2.insert(300); c3 = c2; - + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); UNIT_ASSERT(c3.find(300) != c3.end()); - + c2.insert(400); c3 = std::move(c2); - + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT(c3.find(400) != c3.end()); } - } - + } + struct TKey { TKey() : m_data(0) diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp index c6a0f4981b..e7571c75ec 100644 --- a/util/generic/typetraits_ut.cpp +++ b/util/generic/typetraits_ut.cpp @@ -272,8 +272,8 @@ namespace { enum { IsConstant = false }; enum { IsPointer = false }; enum { IsReference = false }; - enum { IsLvalueReference = false }; - enum { IsRvalueReference = false }; + enum { IsLvalueReference = false }; + enum { IsRvalueReference = false }; enum { IsArray = false }; enum { IsClassType = false }; enum { IsVoid = true }; @@ -332,16 +332,16 @@ namespace { struct TTypeTraitsExpected<TNonPodClass&>: public TTypeTraitsExpected<TNonPodClass> { enum { IsClassType = false }; enum { IsReference = true }; - enum { IsLvalueReference = true }; + enum { IsLvalueReference = true }; }; template <> struct TTypeTraitsExpected<TNonPodClass&&>: public TTypeTraitsExpected<TNonPodClass> { - enum { IsClassType = false }; - enum { IsReference = true }; - enum { IsRvalueReference = true }; - }; - + enum { IsClassType = false }; + enum { IsReference = true }; + enum { IsRvalueReference = true }; + }; + template <> struct TTypeTraitsExpected<const TNonPodClass&>: public TTypeTraitsExpected<TNonPodClass&> { }; @@ -357,17 +357,17 @@ namespace { struct TTypeTraitsExpected<float&>: public TTypeTraitsExpected<float*> { enum { IsPointer = false }; enum { IsReference = true }; - enum { IsLvalueReference = true }; + enum { IsLvalueReference = true }; }; template <> struct TTypeTraitsExpected<float&&>: public TTypeTraitsExpected<float*> { - enum { IsPointer = false }; - enum { IsReference = true }; - enum { IsRvalueReference = true }; - }; - - template <> + enum { IsPointer = false }; + enum { IsReference = true }; + enum { IsRvalueReference = true }; + }; + + template <> struct TTypeTraitsExpected<const float&>: public TTypeTraitsExpected<float&> { }; diff --git a/util/generic/vector.h b/util/generic/vector.h index 1d7421d1c9..a5b258955a 100644 --- a/util/generic/vector.h +++ b/util/generic/vector.h @@ -71,12 +71,12 @@ public: : TBase(src) { } - + inline TVector(TSelf&& src) noexcept : TBase(std::forward<TSelf>(src)) - { - } - + { + } + template <class TIter> inline TVector(TIter first, TIter last) : TBase(first, last) @@ -87,12 +87,12 @@ public: TBase::operator=(src); return *this; } - - inline TSelf& operator=(TSelf&& src) noexcept { + + inline TSelf& operator=(TSelf&& src) noexcept { TBase::operator=(std::forward<TSelf>(src)); - return *this; - } - + return *this; + } + inline TSelf& operator=(std::initializer_list<T> il) { this->assign(il.begin(), il.end()); return *this; diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp index 488451d8f3..0f6b4037a0 100644 --- a/util/generic/vector_ut.cpp +++ b/util/generic/vector_ut.cpp @@ -35,39 +35,39 @@ class TYVectorTest: public TTestBase { private: void TestConstructorsAndAssignments() { using container = TVector<int>; - + container c1; c1.push_back(100); c1.push_back(200); - + container c2(c1); - + UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); UNIT_ASSERT_VALUES_EQUAL(100, c1.at(0)); UNIT_ASSERT_VALUES_EQUAL(200, c2.at(1)); - + container c3(std::move(c1)); - + UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); UNIT_ASSERT_VALUES_EQUAL(100, c3.at(0)); - + c2.push_back(300); c3 = c2; - + UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); UNIT_ASSERT_VALUES_EQUAL(300, c3.at(2)); - + c2.push_back(400); c3 = std::move(c2); - + UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT_VALUES_EQUAL(400, c3.at(3)); } - + inline void TestTildeEmptyToNull() { TVector<int> v; UNIT_ASSERT_EQUAL(nullptr, v.data()); |