1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <charconv>
10#include <string.h>
11
12#include "include/from_chars_floating_point.h"
13#include "include/to_chars_floating_point.h"
14
15_LIBCPP_BEGIN_NAMESPACE_STD
16
17#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
18
19namespace __itoa {
20
21_LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); }
22
23_LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); }
24
25} // namespace __itoa
26
27#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
28
29// The original version of floating-point to_chars was written by Microsoft and
30// contributed with the following license.
31
32// Copyright (c) Microsoft Corporation.
33// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
34
35// This implementation is dedicated to the memory of Mary and Thavatchai.
36
37to_chars_result to_chars(char* __first, char* __last, float __value) {
38 return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
39}
40
41to_chars_result to_chars(char* __first, char* __last, double __value) {
42 return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
43}
44
45to_chars_result to_chars(char* __first, char* __last, long double __value) {
46 return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(
47 __first, __last, static_cast<double>(__value), chars_format{}, 0);
48}
49
50to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
51 return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
52}
53
54to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {
55 return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
56}
57
58to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
59 return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(
60 __first, __last, static_cast<double>(__value), __fmt, 0);
61}
62
63to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
64 return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
65 __first, __last, __value, __fmt, __precision);
66}
67
68to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
69 return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
70 __first, __last, __value, __fmt, __precision);
71}
72
73to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
74 return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
75 __first, __last, static_cast<double>(__value), __fmt, __precision);
76}
77
78template <class _Fp>
79__from_chars_result<_Fp> __from_chars_floating_point(
80 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt) {
81 return std::__from_chars_floating_point_impl<_Fp>(__first, __last, __fmt);
82}
83
84template __from_chars_result<float> __from_chars_floating_point(
85 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
86
87template __from_chars_result<double> __from_chars_floating_point(
88 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
89_LIBCPP_END_NAMESPACE_STD
90

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of libcxx/src/charconv.cpp