Path: blob/main/contrib/llvm-project/libcxx/src/charconv.cpp
35154 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include <charconv>9#include <string.h>1011#include "include/to_chars_floating_point.h"1213_LIBCPP_BEGIN_NAMESPACE_STD1415#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_101617namespace __itoa {1819_LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); }2021_LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); }2223} // namespace __itoa2425#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_102627// The original version of floating-point to_chars was written by Microsoft and28// contributed with the following license.2930// Copyright (c) Microsoft Corporation.31// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception3233// This implementation is dedicated to the memory of Mary and Thavatchai.3435to_chars_result to_chars(char* __first, char* __last, float __value) {36return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);37}3839to_chars_result to_chars(char* __first, char* __last, double __value) {40return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);41}4243to_chars_result to_chars(char* __first, char* __last, long double __value) {44return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(45__first, __last, static_cast<double>(__value), chars_format{}, 0);46}4748to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {49return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);50}5152to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {53return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);54}5556to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {57return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(58__first, __last, static_cast<double>(__value), __fmt, 0);59}6061to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {62return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(63__first, __last, __value, __fmt, __precision);64}6566to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {67return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(68__first, __last, __value, __fmt, __precision);69}7071to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {72return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(73__first, __last, static_cast<double>(__value), __fmt, __precision);74}7576_LIBCPP_END_NAMESPACE_STD777879