diff options
author | yuraaka <yuraaka@yandex-team.ru> | 2022-02-10 16:47:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:05 +0300 |
commit | 5577dc406121f6fb3f45b227c01f4251880193a1 (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 /util/generic | |
parent | 4230543261d7a38ef4dc14785ae0d45f2da43704 (diff) | |
download | ydb-5577dc406121f6fb3f45b227c01f4251880193a1.tar.gz |
Restoring authorship annotation for <yuraaka@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/maybe.h | 6 | ||||
-rw-r--r-- | util/generic/maybe_ut.cpp | 24 | ||||
-rw-r--r-- | util/generic/ptr.h | 6 | ||||
-rw-r--r-- | util/generic/typetraits.h | 30 | ||||
-rw-r--r-- | util/generic/typetraits_ut.cpp | 10 | ||||
-rw-r--r-- | util/generic/vector.h | 10 |
6 files changed, 43 insertions, 43 deletions
diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 2066f6bb7b..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -377,11 +377,11 @@ public: return Defined() ? *this : elseValue; } - template <typename U> + template <typename U> TMaybe<U, Policy> Cast() const { return Defined() ? TMaybe<U, Policy>(*Data()) : TMaybe<U, Policy>(); - } - + } + constexpr explicit operator bool() const noexcept { return Defined(); } diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 289824521a..2c1a425c5e 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -208,19 +208,19 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { TMovable o6 = MakeMaybe<TMovable>(6).GetRef(); UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6); } - + Y_UNIT_TEST(TestCast) { - // Undefined maybe casts to undefined maybe - TMaybe<short> shortMaybe; - const auto undefinedMaybe = shortMaybe.Cast<long>(); - UNIT_ASSERT(!undefinedMaybe.Defined()); - - // Defined maybe casts to defined maybe of another type - shortMaybe = 34; - const auto longMaybe = shortMaybe.Cast<long>(); - UNIT_ASSERT(longMaybe.Defined()); - UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef()); - } + // Undefined maybe casts to undefined maybe + TMaybe<short> shortMaybe; + const auto undefinedMaybe = shortMaybe.Cast<long>(); + UNIT_ASSERT(!undefinedMaybe.Defined()); + + // Defined maybe casts to defined maybe of another type + shortMaybe = 34; + const auto longMaybe = shortMaybe.Cast<long>(); + UNIT_ASSERT(longMaybe.Defined()); + UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef()); + } Y_UNIT_TEST(TestGetOr) { UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx")); diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 4d652175d2..19db0e3ec5 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -818,9 +818,9 @@ public: template <class TT, class = TGuardConversion<T, TT>> inline TSharedPtr(THolder<TT>&& t) { - Init(t); - } - + Init(t); + } + inline ~TSharedPtr() { UnRef(); } diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h index 9cb9527a8d..d165bd1a06 100644 --- a/util/generic/typetraits.h +++ b/util/generic/typetraits.h @@ -4,7 +4,7 @@ #include <util/system/defaults.h> -#include <iterator> +#include <iterator> #include <type_traits> #include <stlfwd> @@ -300,21 +300,21 @@ using TEnableIfTuple = std::enable_if_t<::TDisjunction<::TIsSpecializationOf<std ::TIsSpecializationOf<std::pair, std::decay_t<T>>>::value, R>; -namespace NPrivate { - // To allow ADL with custom begin/end - using std::begin; - using std::end; - - template <typename T> +namespace NPrivate { + // To allow ADL with custom begin/end + using std::begin; + using std::end; + + template <typename T> auto IsIterableImpl(int) -> decltype( begin(std::declval<T&>()) != end(std::declval<T&>()), // begin/end and operator != - ++std::declval<decltype(begin(std::declval<T&>()))&>(), // operator ++ + ++std::declval<decltype(begin(std::declval<T&>()))&>(), // operator ++ *begin(std::declval<T&>()), // operator* std::true_type{}); - - template <typename T> - std::false_type IsIterableImpl(...); -} - -template <typename T> -using TIsIterable = decltype(NPrivate::IsIterableImpl<T>(0)); + + template <typename T> + std::false_type IsIterableImpl(...); +} + +template <typename T> +using TIsIterable = decltype(NPrivate::IsIterableImpl<T>(0)); diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp index 4de0c5377f..e7571c75ec 100644 --- a/util/generic/typetraits_ut.cpp +++ b/util/generic/typetraits_ut.cpp @@ -456,11 +456,11 @@ 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, ""); -static_assert(!TIsIterable<int>::value, ""); -static_assert(TIsIterable<int[42]>::value, ""); + +// test for TIsIterable +static_assert(TIsIterable<std::vector<int>>::value, ""); +static_assert(!TIsIterable<int>::value, ""); +static_assert(TIsIterable<int[42]>::value, ""); // test for TDependentFalse static_assert(TDependentFalse<int> == false); diff --git a/util/generic/vector.h b/util/generic/vector.h index d4ac69180d..a5b258955a 100644 --- a/util/generic/vector.h +++ b/util/generic/vector.h @@ -42,11 +42,11 @@ public: { } - inline explicit TVector(size_type count, const typename TBase::allocator_type& a) - : TBase(count, a) - { - } - + inline explicit TVector(size_type count, const typename TBase::allocator_type& a) + : TBase(count, a) + { + } + inline TVector(size_type count, const T& val) : TBase(count, val) { |