diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-23 13:46:40 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-23 13:46:40 +0300 |
commit | 487e08c67742f8b922086c123e2ed1e08d6e8080 (patch) | |
tree | fddd2fca24b4e284080caa5db3d4a8d85967392f /contrib/libs/cxxsupp/libcxx/src/charconv.cpp | |
parent | a90605734f5718f64ebc9b0a0883c0f33352dd75 (diff) | |
download | ydb-487e08c67742f8b922086c123e2ed1e08d6e8080.tar.gz |
intermediate changes
ref:e2259743aaaa198850a5184b92813fca8eb3a49b
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src/charconv.cpp')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/src/charconv.cpp | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp index 533e59b04d..60ec3eccc9 100644 --- a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp @@ -9,27 +9,14 @@ #include "charconv" #include <string.h> +#include "include/ryu/digit_table.h" +#include "include/to_chars_floating_point.h" + _LIBCPP_BEGIN_NAMESPACE_STD namespace __itoa { -static constexpr char cDigitsLut[200] = { - '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', - '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', - '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', - '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', - '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', - '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', - '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', - '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', - '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', - '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', - '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', - '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', - '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', - '7', '9', '8', '9', '9'}; - template <typename T> inline _LIBCPP_INLINE_VISIBILITY char* append1(char* buffer, T i) noexcept @@ -42,7 +29,7 @@ template <typename T> inline _LIBCPP_INLINE_VISIBILITY char* append2(char* buffer, T i) noexcept { - memcpy(buffer, &cDigitsLut[(i)*2], 2); + memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2); return buffer + 2; } @@ -157,4 +144,53 @@ __u64toa(uint64_t value, char* buffer) noexcept } // namespace __itoa +// The original version of floating-point to_chars was written by Microsoft and +// contributed with the following license. + +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// This implementation is dedicated to the memory of Mary and Thavatchai. + +to_chars_result to_chars(char* __first, char* __last, float __value) { + return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0); +} + +to_chars_result to_chars(char* __first, char* __last, double __value) { + return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0); +} + +to_chars_result to_chars(char* __first, char* __last, long double __value) { + return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value), + chars_format{}, 0); +} + +to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0); +} + +to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0); +} + +to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value), + __fmt, 0); +} + +to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt, + __precision); +} + +to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt, + __precision); +} + +to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) { + return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>( + __first, __last, static_cast<double>(__value), __fmt, __precision); +} + _LIBCPP_END_NAMESPACE_STD |