diff options
author | the0 <the0@yandex-team.ru> | 2022-02-10 16:51:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:52 +0300 |
commit | 6ab3ef1bf61ea8fc15ead03026798320e25c5455 (patch) | |
tree | 1e7596e57f9b2c070185325ad557906741994ec6 /util/generic | |
parent | 31b5d49128f87d4f12ef17f7e681620416030f5c (diff) | |
download | ydb-6ab3ef1bf61ea8fc15ead03026798320e25c5455.tar.gz |
Restoring authorship annotation for <the0@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/lazy_value.h | 6 | ||||
-rw-r--r-- | util/generic/lazy_value_ut.cpp | 90 |
2 files changed, 48 insertions, 48 deletions
diff --git a/util/generic/lazy_value.h b/util/generic/lazy_value.h index 3c720f76b5..447886977b 100644 --- a/util/generic/lazy_value.h +++ b/util/generic/lazy_value.h @@ -9,9 +9,9 @@ public: using TInitializer = std::function<T()>; TLazyValueBase() = default; - - TLazyValueBase(TInitializer initializer) - : Initializer(std::move(initializer)) + + TLazyValueBase(TInitializer initializer) + : Initializer(std::move(initializer)) { } diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp index f6135880c3..faca68d03f 100644 --- a/util/generic/lazy_value_ut.cpp +++ b/util/generic/lazy_value_ut.cpp @@ -42,53 +42,53 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { UNIT_ASSERT_EQUAL(*notEmptyCopy, 5); } - struct TCopyCounter { - TCopyCounter(size_t& numCopies) - : NumCopies(&numCopies) - { - } - - TCopyCounter() = default; - - TCopyCounter(const TCopyCounter& other) - : NumCopies(other.NumCopies) - { - ++(*NumCopies); - } - - TCopyCounter(TCopyCounter&&) = default; - - TCopyCounter& operator=(const TCopyCounter& other) { - if (this == &other) { - return *this; - } - NumCopies = other.NumCopies; - ++(*NumCopies); - return *this; - } - - TCopyCounter& operator=(TCopyCounter&&) = default; - - size_t* NumCopies = nullptr; - }; - - Y_UNIT_TEST(TestLazyValueMoveValueInitialization) { - size_t numCopies = 0; - TCopyCounter counter{numCopies}; + struct TCopyCounter { + TCopyCounter(size_t& numCopies) + : NumCopies(&numCopies) + { + } + + TCopyCounter() = default; + + TCopyCounter(const TCopyCounter& other) + : NumCopies(other.NumCopies) + { + ++(*NumCopies); + } + + TCopyCounter(TCopyCounter&&) = default; + + TCopyCounter& operator=(const TCopyCounter& other) { + if (this == &other) { + return *this; + } + NumCopies = other.NumCopies; + ++(*NumCopies); + return *this; + } + + TCopyCounter& operator=(TCopyCounter&&) = default; + + size_t* NumCopies = nullptr; + }; + + Y_UNIT_TEST(TestLazyValueMoveValueInitialization) { + size_t numCopies = 0; + TCopyCounter counter{numCopies}; TLazyValue<TCopyCounter> value{[v = std::move(counter)]() mutable { return std::move(v); }}; - value.InitDefault(); - UNIT_ASSERT_EQUAL(numCopies, 0); - } - - Y_UNIT_TEST(TestLazyValueCopyValueInitialization) { - size_t numCopies = 0; - TCopyCounter counter{numCopies}; + value.InitDefault(); + UNIT_ASSERT_EQUAL(numCopies, 0); + } + + Y_UNIT_TEST(TestLazyValueCopyValueInitialization) { + size_t numCopies = 0; + TCopyCounter counter{numCopies}; TLazyValue<TCopyCounter> value{[&counter]() { return counter; }}; - UNIT_ASSERT_EQUAL(numCopies, 0); - value.InitDefault(); - UNIT_ASSERT_EQUAL(numCopies, 1); - } - + UNIT_ASSERT_EQUAL(numCopies, 0); + value.InitDefault(); + UNIT_ASSERT_EQUAL(numCopies, 1); + } + class TValueProvider { public: static size_t CountParseDataCalled; |