diff options
| author | Dmitry Potapov <[email protected]> | 2022-02-10 16:46:39 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:39 +0300 | 
| commit | 536101ea75c9ff5df10d01c2f460b1f6e12311b3 (patch) | |
| tree | 115291277ad61b2cdcf5044d210fb103b5e1647e /util/generic | |
| parent | 5036b5f2122001f9aef8a0e4cd85440d73ea6b9f (diff) | |
Restoring authorship annotation for Dmitry Potapov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
| -rw-r--r-- | util/generic/cast.h | 34 | ||||
| -rw-r--r-- | util/generic/string.h | 8 | ||||
| -rw-r--r-- | util/generic/typelist.h | 2 | ||||
| -rw-r--r-- | util/generic/yexception.h | 4 | ||||
| -rw-r--r-- | util/generic/ylimits.h | 36 | ||||
| -rw-r--r-- | util/generic/ylimits_ut.cpp | 12 | 
6 files changed, 48 insertions, 48 deletions
| diff --git a/util/generic/cast.h b/util/generic/cast.h index 0d4a41f385b..0d680f90bdd 100644 --- a/util/generic/cast.h +++ b/util/generic/cast.h @@ -1,14 +1,14 @@  #pragma once  #include "typetraits.h" -#include "yexception.h" +#include "yexception.h"   #include <util/system/compat.h>  #include <util/system/type_name.h>  #include <util/system/unaligned_mem.h>  #include <util/system/yassert.h> -#include <cstdlib> +#include <cstdlib>   template <class T, class F>  static inline T VerifyDynamicCast(F f) { @@ -87,7 +87,7 @@ constexpr bool IsNegative(const TType value) noexcept {      return TInteger<std::is_unsigned<TType>::value>::IsNegative(value);  } -namespace NPrivate { +namespace NPrivate {       template <class T>      using TUnderlyingTypeOrSelf = typename std::conditional<          std::is_enum<T>::value, @@ -96,21 +96,21 @@ namespace NPrivate {          >::type::type;           // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if      template <class TSmall, class TLarge> -    struct TSafelyConvertible { +    struct TSafelyConvertible {           using TSmallInt = TUnderlyingTypeOrSelf<TSmall>;          using TLargeInt = TUnderlyingTypeOrSelf<TLarge>;          static constexpr bool Result = std::is_integral<TSmallInt>::value && std::is_integral<TLargeInt>::value &&                                         ((std::is_signed<TSmallInt>::value == std::is_signed<TLargeInt>::value && sizeof(TSmallInt) >= sizeof(TLargeInt)) ||                                          (std::is_signed<TSmallInt>::value && sizeof(TSmallInt) > sizeof(TLargeInt))); -    }; -} - +    };  +}  +   template <class TSmallInt, class TLargeInt>  constexpr std::enable_if_t<::NPrivate::TSafelyConvertible<TSmallInt, TLargeInt>::Result, TSmallInt> SafeIntegerCast(TLargeInt largeInt) noexcept {      return static_cast<TSmallInt>(largeInt); -} - +}  +   template <class TSmall, class TLarge>  inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) {      using TSmallInt = ::NPrivate::TUnderlyingTypeOrSelf<TSmall>; @@ -127,7 +127,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 (IsNegative(smallInt)) { +        if (IsNegative(smallInt)) {               ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"                                         << TypeName<TSmallInt>()                                         << "', positive value converted to negative"; @@ -141,15 +141,15 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,      return static_cast<TSmall>(smallInt);  } - -template <class TSmallInt, class TLargeInt> +  +template <class TSmallInt, class TLargeInt>   inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept { -    try { -        return SafeIntegerCast<TSmallInt>(largeInt); -    } catch (const yexception& exc) { +    try {  +        return SafeIntegerCast<TSmallInt>(largeInt);  +    } catch (const yexception& exc) {           Y_FAIL("IntegerCast: %s", exc.what()); -    } -} +    }  +}   /* Convert given enum value to its underlying type. This is just a shortcut for   * `static_cast<std::underlying_type_t<EEnum>>(enum_)`. diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917f..61a4bd55ef5 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -864,7 +864,7 @@ public:       */      friend TBasicString operator+(TBasicString&& s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT { -        s1 += s2; +        s1 += s2;           return std::move(s1);      } @@ -880,17 +880,17 @@ public:              return std::move(s2);          }  #endif -        s1 += s2; +        s1 += s2;           return std::move(s1);      }      friend TBasicString operator+(TBasicString&& s1, const TBasicStringBuf<TCharType, TTraits> s2) Y_WARN_UNUSED_RESULT { -        s1 += s2; +        s1 += s2;           return std::move(s1);      }      friend TBasicString operator+(TBasicString&& s1, const TCharType* s2) Y_WARN_UNUSED_RESULT { -        s1 += s2; +        s1 += s2;           return std::move(s1);      } diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 5ce26ab97c7..7f2a3167488 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -80,7 +80,7 @@ namespace NTL {          using TSignedInts = typename TConcat<TTypeList<T>, TS>::type;          using TUnsignedInts = TU;      }; - +       template <class T, class TS, class TU>      struct TTypeSelectorBase<false, T, TS, TU> {          using TSignedInts = TS; diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c45..51f7bde0501 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -129,8 +129,8 @@ class TFileError: public TIoSystemError {   * TBadArgumentException.   */  struct TBadArgumentException: public virtual yexception { -}; - +};  +   /**   * TBadCastException should be thrown to indicate the failure of some type casting procedure   * (e.g. reading an integer parameter from string). diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h index fe42b4dfc0e..599effa4811 100644 --- a/util/generic/ylimits.h +++ b/util/generic/ylimits.h @@ -15,30 +15,30 @@ template <class T>  static constexpr T Min() noexcept {      return std::numeric_limits<T>::min();  } - -namespace NPrivate { -    struct TMax { -        template <class T> +  +namespace NPrivate {  +    struct TMax {  +        template <class T>           constexpr operator T() const { -            return Max<T>(); -        } -    }; - -    struct TMin { -        template <class T> +            return Max<T>();  +        }  +    };  +  +    struct TMin {  +        template <class T>           constexpr operator T() const { -            return Min<T>(); -        } -    }; -} - +            return Min<T>();  +        }  +    };  +}  +   static constexpr ::NPrivate::TMax Max() noexcept {      return {}; -} - +}  +   static constexpr ::NPrivate::TMin Min() noexcept {      return {}; -} +}   namespace NPrivate {      template <unsigned long long N> diff --git a/util/generic/ylimits_ut.cpp b/util/generic/ylimits_ut.cpp index f1b3c6858cf..3a0a70adc95 100644 --- a/util/generic/ylimits_ut.cpp +++ b/util/generic/ylimits_ut.cpp @@ -1,4 +1,4 @@ -#include "cast.h" +#include "cast.h"   #include "ylimits.h"  #include <library/cpp/testing/unittest/registar.h> @@ -42,11 +42,11 @@ static inline bool TestIntegralLimits(const T&, bool unknownSign = true, bool is      CHECK_COND((unknownSign && ((lim::is_signed && (lim::min() != 0)) || (!lim::is_signed && (lim::min() == 0)))) ||                 (!unknownSign && ((lim::is_signed && isSigned) || (!lim::is_signed && !isSigned)))); -    T min = Min(); -    UNIT_ASSERT_EQUAL(lim::min(), min); -    T max = Max(); -    UNIT_ASSERT_EQUAL(lim::max(), max); - +    T min = Min();  +    UNIT_ASSERT_EQUAL(lim::min(), min);  +    T max = Max();  +    UNIT_ASSERT_EQUAL(lim::max(), max);  +       if (unknownSign) {          CHECK_COND(ValidSignInfo(lim::is_signed, T()));      } | 
