diff options
author | ivanmorozov <ivanmorozov@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
commit | 464ba3814a83db4f2d5327393b0b6eaf0c86bfd7 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /util/generic | |
parent | cba5d9a444e2cfe105f55ccda66cd21d50440017 (diff) | |
download | ydb-464ba3814a83db4f2d5327393b0b6eaf0c86bfd7.tar.gz |
Restoring authorship annotation for <ivanmorozov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/maybe.h | 22 | ||||
-rw-r--r-- | util/generic/object_counter.h | 8 | ||||
-rw-r--r-- | util/generic/objects_counter_ut.cpp | 60 | ||||
-rw-r--r-- | util/generic/ut/ya.make | 2 |
4 files changed, 46 insertions, 46 deletions
diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 37d9cf435e..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -9,16 +9,16 @@ #include <util/stream/output.h> #include <util/ysaveload.h> -namespace NMaybe { - struct TPolicyUndefinedExcept { +namespace NMaybe { + struct TPolicyUndefinedExcept { [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); - }; - - struct TPolicyUndefinedFail { + }; + + struct TPolicyUndefinedFail { [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); - }; -} - + }; +} + struct TNothing { explicit constexpr TNothing(int) noexcept { } @@ -448,9 +448,9 @@ private: } }; -template <class T> -using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>; - +template <class T> +using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>; + template <class T, class TPolicy = ::NMaybe::TPolicyUndefinedExcept> constexpr TMaybe<std::decay_t<T>, TPolicy> MakeMaybe(T&& value) { return TMaybe<std::decay_t<T>, TPolicy>(std::forward<T>(value)); diff --git a/util/generic/object_counter.h b/util/generic/object_counter.h index 56635bcc42..5257afa2e6 100644 --- a/util/generic/object_counter.h +++ b/util/generic/object_counter.h @@ -23,10 +23,10 @@ public: AtomicIncrement(Count_); } - inline TObjectCounter(const TObjectCounter& /*item*/) noexcept { - AtomicIncrement(Count_); - } - + inline TObjectCounter(const TObjectCounter& /*item*/) noexcept { + AtomicIncrement(Count_); + } + inline ~TObjectCounter() { AtomicDecrement(Count_); } diff --git a/util/generic/objects_counter_ut.cpp b/util/generic/objects_counter_ut.cpp index d12a1e78c6..4d5da37a56 100644 --- a/util/generic/objects_counter_ut.cpp +++ b/util/generic/objects_counter_ut.cpp @@ -1,36 +1,36 @@ -#include "object_counter.h" - +#include "object_counter.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(ObjectsCounter) { - struct TObject: public TObjectCounter<TObject> { - }; - + struct TObject: public TObjectCounter<TObject> { + }; + Y_UNIT_TEST(Test1) { - TObject obj; + TObject obj; TVector<TObject> objects; - for (ui32 i = 0; i < 100; ++i) { - objects.push_back(obj); - } - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 101); - } - + for (ui32 i = 0; i < 100; ++i) { + objects.push_back(obj); + } + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 101); + } + Y_UNIT_TEST(TestEq) { - TObject obj; - { - TObject obj1 = obj; - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 2); - } - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); - } - + TObject obj; + { + TObject obj1 = obj; + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 2); + } + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); + } + Y_UNIT_TEST(TestMove) { - TObject obj; - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); - { - TObject obj1 = std::move(obj); - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 2); - } - UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); - } -} + TObject obj; + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); + { + TObject obj1 = std::move(obj); + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 2); + } + UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); + } +} diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make index 89edb7f2b7..6eaf24cc5f 100644 --- a/util/generic/ut/ya.make +++ b/util/generic/ut/ya.make @@ -31,7 +31,7 @@ SRCS( generic/mapfindptr_ut.cpp generic/maybe_ut.cpp generic/mem_copy_ut.cpp - generic/objects_counter_ut.cpp + generic/objects_counter_ut.cpp generic/overloaded_ut.cpp generic/ptr_ut.cpp generic/queue_ut.cpp |