diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-02-10 16:46:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:30 +0300 |
commit | 4b839d0704ee9be1dabb0310a1f03af24963637b (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/cxxsupp/libcxx/include/charconv | |
parent | f773626848a7c7456803654292e716b83d69cc12 (diff) | |
download | ydb-4b839d0704ee9be1dabb0310a1f03af24963637b.tar.gz |
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/charconv')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/charconv | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/charconv b/contrib/libs/cxxsupp/libcxx/include/charconv index 88cb90c16d..2fdab7f007 100644 --- a/contrib/libs/cxxsupp/libcxx/include/charconv +++ b/contrib/libs/cxxsupp/libcxx/include/charconv @@ -73,18 +73,18 @@ namespace std { */ -#include <__availability> -#include <__bits> -#include <__charconv/chars_format.h> -#include <__charconv/from_chars_result.h> -#include <__charconv/to_chars_result.h> -#include <__config> +#include <__availability> +#include <__bits> +#include <__charconv/chars_format.h> +#include <__charconv/from_chars_result.h> +#include <__charconv/to_chars_result.h> +#include <__config> #include <__errc> -#include <cmath> // for log2f -#include <cstdint> -#include <cstdlib> // for _LIBCPP_UNREACHABLE -#include <cstring> -#include <limits> +#include <cmath> // for log2f +#include <cstdint> +#include <cstdlib> // for _LIBCPP_UNREACHABLE +#include <cstring> +#include <limits> #include <type_traits> #include <__debug> @@ -99,11 +99,11 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace __itoa { -_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; -_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; +_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; +_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; } -#ifndef _LIBCPP_CXX03_LANG +#ifndef _LIBCPP_CXX03_LANG void to_chars(char*, char*, bool, int = 10) = delete; void from_chars(const char*, const char*, bool, int = 10) = delete; @@ -111,7 +111,7 @@ void from_chars(const char*, const char*, bool, int = 10) = delete; namespace __itoa { -static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = { +static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = { UINT64_C(0), UINT64_C(10), UINT64_C(100), @@ -134,7 +134,7 @@ static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = { UINT64_C(10000000000000000000), }; -static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = { +static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = { UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000), UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), @@ -148,17 +148,17 @@ struct _LIBCPP_HIDDEN __traits_base static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) { - auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; + auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; return __t - (__v < __pow10_64[__t]) + 1; } - _LIBCPP_AVAILABILITY_TO_CHARS + _LIBCPP_AVAILABILITY_TO_CHARS static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) { return __u64toa(__v, __p); } - static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; } + static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; } }; template <typename _Tp> @@ -169,17 +169,17 @@ struct _LIBCPP_HIDDEN static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) { - auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; + auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; return __t - (__v < __pow10_32[__t]) + 1; } - _LIBCPP_AVAILABILITY_TO_CHARS + _LIBCPP_AVAILABILITY_TO_CHARS static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) { return __u32toa(__v, __p); } - static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; } + static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; } }; template <typename _Tp> @@ -188,7 +188,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r) { auto __c = __a * __b; __r = __c; - return __c > numeric_limits<unsigned char>::max(); + return __c > numeric_limits<unsigned char>::max(); } template <typename _Tp> @@ -197,7 +197,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) { auto __c = __a * __b; __r = __c; - return __c > numeric_limits<unsigned short>::max(); + return __c > numeric_limits<unsigned short>::max(); } template <typename _Tp> @@ -208,7 +208,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) #if !defined(_LIBCPP_COMPILER_MSVC) return __builtin_mul_overflow(__a, __b, &__r); #else - bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a; + bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a; __r = __a * __b; return __did; #endif @@ -224,7 +224,7 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r) template <typename _Tp> struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> { - static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1; + static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1; using __traits_base<_Tp>::__pow; using typename __traits_base<_Tp>::type; @@ -270,11 +270,11 @@ __complement(_Tp __x) } template <typename _Tp> -_LIBCPP_AVAILABILITY_TO_CHARS +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) { - auto __x = __to_unsigned_like(__value); + auto __x = __to_unsigned_like(__value); if (__value < 0 && __first != __last) { *__first++ = '-'; @@ -285,7 +285,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) } template <typename _Tp> -_LIBCPP_AVAILABILITY_TO_CHARS +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { @@ -293,18 +293,18 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) auto __diff = __last - __first; if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) - return {__tx::__convert(__value, __first), errc(0)}; + return {__tx::__convert(__value, __first), errc(0)}; else return {__last, errc::value_too_large}; } template <typename _Tp> -_LIBCPP_AVAILABILITY_TO_CHARS +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, true_type) { - auto __x = __to_unsigned_like(__value); + auto __x = __to_unsigned_like(__value); if (__value < 0 && __first != __last) { *__first++ = '-'; @@ -315,65 +315,65 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, } template <typename _Tp> -_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) { - _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value."); - - unsigned __base_2 = __base * __base; - unsigned __base_3 = __base_2 * __base; - unsigned __base_4 = __base_2 * __base_2; - - int __r = 0; - while (true) { - if (__value < __base) - return __r + 1; - if (__value < __base_2) - return __r + 2; - if (__value < __base_3) - return __r + 3; - if (__value < __base_4) - return __r + 4; - - __value /= __base_4; - __r += 4; - } - - _LIBCPP_UNREACHABLE(); -} - -template <typename _Tp> -_LIBCPP_AVAILABILITY_TO_CHARS +_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) { + _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value."); + + unsigned __base_2 = __base * __base; + unsigned __base_3 = __base_2 * __base; + unsigned __base_4 = __base_2 * __base_2; + + int __r = 0; + while (true) { + if (__value < __base) + return __r + 1; + if (__value < __base_2) + return __r + 2; + if (__value < __base_3) + return __r + 3; + if (__value < __base_4) + return __r + 4; + + __value /= __base_4; + __r += 4; + } + + _LIBCPP_UNREACHABLE(); +} + +template <typename _Tp> +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) { - if (__base == 10) - return __to_chars_itoa(__first, __last, __value, false_type()); - - ptrdiff_t __cap = __last - __first; - int __n = __to_chars_integral_width(__value, __base); - if (__n > __cap) - return {__last, errc::value_too_large}; - - __last = __first + __n; - char* __p = __last; - do { - unsigned __c = __value % __base; - __value /= __base; - *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c]; - } while (__value != 0); - return {__last, errc(0)}; + if (__base == 10) + return __to_chars_itoa(__first, __last, __value, false_type()); + + ptrdiff_t __cap = __last - __first; + int __n = __to_chars_integral_width(__value, __base); + if (__n > __cap) + return {__last, errc::value_too_large}; + + __last = __first + __n; + char* __p = __last; + do { + unsigned __c = __value % __base; + __value /= __base; + *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c]; + } while (__value != 0); + return {__last, errc(0)}; } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> -_LIBCPP_AVAILABILITY_TO_CHARS +template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result to_chars(char* __first, char* __last, _Tp __value) { return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>()); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> -_LIBCPP_AVAILABILITY_TO_CHARS +template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +_LIBCPP_AVAILABILITY_TO_CHARS inline _LIBCPP_INLINE_VISIBILITY to_chars_result to_chars(char* __first, char* __last, _Tp __value, int __base) { @@ -387,7 +387,7 @@ inline _LIBCPP_INLINE_VISIBILITY from_chars_result __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args) { using __tl = numeric_limits<_Tp>; - decltype(__to_unsigned_like(__value)) __x; + decltype(__to_unsigned_like(__value)) __x; bool __neg = (__first != __last && *__first == '-'); auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...); @@ -403,16 +403,16 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args) if (__neg) { - if (__x <= __complement(__to_unsigned_like(__tl::min()))) + if (__x <= __complement(__to_unsigned_like(__tl::min()))) { __x = __complement(__x); - _VSTD::memcpy(&__value, &__x, sizeof(__x)); + _VSTD::memcpy(&__value, &__x, sizeof(__x)); return __r; } } else { - if (__x <= __tl::max()) + if (__x <= __tl::max()) { __value = __x; return __r; @@ -488,7 +488,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, return __r; } -template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) { @@ -503,7 +503,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) auto __p = __tx::__read(__first, __last, __a, __b); if (__p == __last || !__in_pattern(*__p)) { - __output_type __m = numeric_limits<_Tp>::max(); + __output_type __m = numeric_limits<_Tp>::max(); if (__m >= __a && __m - __a >= __b) { __value = __a + __b; @@ -514,15 +514,15 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) }); } -template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) { - using __t = decltype(__to_unsigned_like(__value)); + using __t = decltype(__to_unsigned_like(__value)); return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>); } -template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) @@ -532,13 +532,13 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, return __subject_seq_combinator( __first, __last, __value, - [](const char* __p, const char* __lastx, _Tp& __value, + [](const char* __p, const char* __lastx, _Tp& __value, int __base) -> from_chars_result { using __tl = numeric_limits<_Tp>; auto __digits = __tl::digits / log2f(float(__base)); _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0; - for (int __i = 1; __p != __lastx; ++__i, ++__p) + for (int __i = 1; __p != __lastx; ++__i, ++__p) { if (auto __c = __in_pattern(*__p, __base)) { @@ -556,9 +556,9 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, break; } - if (__p == __lastx || !__in_pattern(*__p, __base)) + if (__p == __lastx || !__in_pattern(*__p, __base)) { - if (__tl::max() - __a >= __b) + if (__tl::max() - __a >= __b) { __value = __a + __b; return {__p, {}}; @@ -569,24 +569,24 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, __base); } -template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) { - using __t = decltype(__to_unsigned_like(__value)); + using __t = decltype(__to_unsigned_like(__value)); return __sign_combinator(__first, __last, __value, __from_chars_integral<__t>, __base); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result from_chars(const char* __first, const char* __last, _Tp& __value) { return __from_chars_atoi(__first, __last, __value); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> inline _LIBCPP_INLINE_VISIBILITY from_chars_result from_chars(const char* __first, const char* __last, _Tp& __value, int __base) { @@ -594,10 +594,10 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base) return __from_chars_integral(__first, __last, __value, __base); } -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP_CHARCONV +#endif // _LIBCPP_CHARCONV |