charconv 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_CHARCONV
  10. #define _LIBCPP_CHARCONV
  11. /*
  12. charconv synopsis
  13. namespace std {
  14. // floating-point format for primitive numerical conversion
  15. enum class chars_format {
  16. scientific = unspecified,
  17. fixed = unspecified,
  18. hex = unspecified,
  19. general = fixed | scientific
  20. };
  21. // 23.20.2, primitive numerical output conversion
  22. struct to_chars_result {
  23. char* ptr;
  24. errc ec;
  25. friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20
  26. };
  27. to_chars_result to_chars(char* first, char* last, see below value,
  28. int base = 10);
  29. to_chars_result to_chars(char* first, char* last, bool value,
  30. int base = 10) = delete;
  31. to_chars_result to_chars(char* first, char* last, float value);
  32. to_chars_result to_chars(char* first, char* last, double value);
  33. to_chars_result to_chars(char* first, char* last, long double value);
  34. to_chars_result to_chars(char* first, char* last, float value,
  35. chars_format fmt);
  36. to_chars_result to_chars(char* first, char* last, double value,
  37. chars_format fmt);
  38. to_chars_result to_chars(char* first, char* last, long double value,
  39. chars_format fmt);
  40. to_chars_result to_chars(char* first, char* last, float value,
  41. chars_format fmt, int precision);
  42. to_chars_result to_chars(char* first, char* last, double value,
  43. chars_format fmt, int precision);
  44. to_chars_result to_chars(char* first, char* last, long double value,
  45. chars_format fmt, int precision);
  46. // 23.20.3, primitive numerical input conversion
  47. struct from_chars_result {
  48. const char* ptr;
  49. errc ec;
  50. friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20
  51. };
  52. from_chars_result from_chars(const char* first, const char* last,
  53. see below& value, int base = 10);
  54. from_chars_result from_chars(const char* first, const char* last,
  55. float& value,
  56. chars_format fmt = chars_format::general);
  57. from_chars_result from_chars(const char* first, const char* last,
  58. double& value,
  59. chars_format fmt = chars_format::general);
  60. from_chars_result from_chars(const char* first, const char* last,
  61. long double& value,
  62. chars_format fmt = chars_format::general);
  63. } // namespace std
  64. */
  65. #include <__availability>
  66. #include <__bits>
  67. #include <__charconv/chars_format.h>
  68. #include <__charconv/from_chars_result.h>
  69. #include <__charconv/to_chars_result.h>
  70. #include <__config>
  71. #include <__errc>
  72. #include <cmath> // for log2f
  73. #include <cstdint>
  74. #include <cstdlib> // for _LIBCPP_UNREACHABLE
  75. #include <cstring>
  76. #include <limits>
  77. #include <type_traits>
  78. #include <__debug>
  79. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  80. #pragma GCC system_header
  81. #endif
  82. _LIBCPP_PUSH_MACROS
  83. #include <__undef_macros>
  84. _LIBCPP_BEGIN_NAMESPACE_STD
  85. namespace __itoa {
  86. _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT;
  87. _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT;
  88. } // namespace __itoa
  89. #ifndef _LIBCPP_CXX03_LANG
  90. to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
  91. from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
  92. namespace __itoa
  93. {
  94. static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = {
  95. UINT64_C(0),
  96. UINT64_C(10),
  97. UINT64_C(100),
  98. UINT64_C(1000),
  99. UINT64_C(10000),
  100. UINT64_C(100000),
  101. UINT64_C(1000000),
  102. UINT64_C(10000000),
  103. UINT64_C(100000000),
  104. UINT64_C(1000000000),
  105. UINT64_C(10000000000),
  106. UINT64_C(100000000000),
  107. UINT64_C(1000000000000),
  108. UINT64_C(10000000000000),
  109. UINT64_C(100000000000000),
  110. UINT64_C(1000000000000000),
  111. UINT64_C(10000000000000000),
  112. UINT64_C(100000000000000000),
  113. UINT64_C(1000000000000000000),
  114. UINT64_C(10000000000000000000),
  115. };
  116. static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = {
  117. UINT32_C(0), UINT32_C(10), UINT32_C(100),
  118. UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
  119. UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
  120. UINT32_C(1000000000),
  121. };
  122. template <typename _Tp, typename = void>
  123. struct _LIBCPP_HIDDEN __traits_base
  124. {
  125. using type = uint64_t;
  126. static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
  127. {
  128. auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
  129. return __t - (__v < __pow10_64[__t]) + 1;
  130. }
  131. _LIBCPP_AVAILABILITY_TO_CHARS
  132. static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
  133. {
  134. return __u64toa(__v, __p);
  135. }
  136. static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; }
  137. };
  138. template <typename _Tp>
  139. struct _LIBCPP_HIDDEN
  140. __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>
  141. {
  142. using type = uint32_t;
  143. static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
  144. {
  145. auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
  146. return __t - (__v < __pow10_32[__t]) + 1;
  147. }
  148. _LIBCPP_AVAILABILITY_TO_CHARS
  149. static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
  150. {
  151. return __u32toa(__v, __p);
  152. }
  153. static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; }
  154. };
  155. template <typename _Tp>
  156. inline _LIBCPP_INLINE_VISIBILITY bool
  157. __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
  158. {
  159. auto __c = __a * __b;
  160. __r = __c;
  161. return __c > numeric_limits<unsigned char>::max();
  162. }
  163. template <typename _Tp>
  164. inline _LIBCPP_INLINE_VISIBILITY bool
  165. __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
  166. {
  167. auto __c = __a * __b;
  168. __r = __c;
  169. return __c > numeric_limits<unsigned short>::max();
  170. }
  171. template <typename _Tp>
  172. inline _LIBCPP_INLINE_VISIBILITY bool
  173. __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
  174. {
  175. static_assert(is_unsigned<_Tp>::value, "");
  176. #if !defined(_LIBCPP_COMPILER_MSVC)
  177. return __builtin_mul_overflow(__a, __b, &__r);
  178. #else
  179. bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
  180. __r = __a * __b;
  181. return __did;
  182. #endif
  183. }
  184. template <typename _Tp, typename _Up>
  185. inline _LIBCPP_INLINE_VISIBILITY bool
  186. __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
  187. {
  188. return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
  189. }
  190. template <typename _Tp>
  191. struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
  192. {
  193. static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1;
  194. using __traits_base<_Tp>::__pow;
  195. using typename __traits_base<_Tp>::type;
  196. // precondition: at least one non-zero character available
  197. static _LIBCPP_INLINE_VISIBILITY char const*
  198. __read(char const* __p, char const* __ep, type& __a, type& __b)
  199. {
  200. type __cprod[digits];
  201. int __j = digits - 1;
  202. int __i = digits;
  203. do
  204. {
  205. if (!('0' <= *__p && *__p <= '9'))
  206. break;
  207. __cprod[--__i] = *__p++ - '0';
  208. } while (__p != __ep && __i != 0);
  209. __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
  210. __cprod[__i]);
  211. if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
  212. --__p;
  213. return __p;
  214. }
  215. template <typename _It1, typename _It2, class _Up>
  216. static _LIBCPP_INLINE_VISIBILITY _Up
  217. __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
  218. {
  219. for (; __first1 < __last1; ++__first1, ++__first2)
  220. __init = __init + *__first1 * *__first2;
  221. return __init;
  222. }
  223. };
  224. } // namespace __itoa
  225. template <typename _Tp>
  226. inline _LIBCPP_INLINE_VISIBILITY _Tp
  227. __complement(_Tp __x)
  228. {
  229. static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
  230. return _Tp(~__x + 1);
  231. }
  232. template <typename _Tp>
  233. _LIBCPP_AVAILABILITY_TO_CHARS
  234. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  235. __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
  236. {
  237. auto __x = __to_unsigned_like(__value);
  238. if (__value < 0 && __first != __last)
  239. {
  240. *__first++ = '-';
  241. __x = __complement(__x);
  242. }
  243. return __to_chars_itoa(__first, __last, __x, false_type());
  244. }
  245. template <typename _Tp>
  246. _LIBCPP_AVAILABILITY_TO_CHARS
  247. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  248. __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
  249. {
  250. using __tx = __itoa::__traits<_Tp>;
  251. auto __diff = __last - __first;
  252. if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
  253. return {__tx::__convert(__value, __first), errc(0)};
  254. else
  255. return {__last, errc::value_too_large};
  256. }
  257. template <typename _Tp>
  258. _LIBCPP_AVAILABILITY_TO_CHARS
  259. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  260. __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
  261. true_type)
  262. {
  263. auto __x = __to_unsigned_like(__value);
  264. if (__value < 0 && __first != __last)
  265. {
  266. *__first++ = '-';
  267. __x = __complement(__x);
  268. }
  269. return __to_chars_integral(__first, __last, __x, __base, false_type());
  270. }
  271. template <typename _Tp>
  272. _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) {
  273. _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
  274. unsigned __base_2 = __base * __base;
  275. unsigned __base_3 = __base_2 * __base;
  276. unsigned __base_4 = __base_2 * __base_2;
  277. int __r = 0;
  278. while (true) {
  279. if (__value < __base)
  280. return __r + 1;
  281. if (__value < __base_2)
  282. return __r + 2;
  283. if (__value < __base_3)
  284. return __r + 3;
  285. if (__value < __base_4)
  286. return __r + 4;
  287. __value /= __base_4;
  288. __r += 4;
  289. }
  290. _LIBCPP_UNREACHABLE();
  291. }
  292. template <typename _Tp>
  293. _LIBCPP_AVAILABILITY_TO_CHARS
  294. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  295. __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
  296. false_type)
  297. {
  298. if (__base == 10)
  299. return __to_chars_itoa(__first, __last, __value, false_type());
  300. ptrdiff_t __cap = __last - __first;
  301. int __n = __to_chars_integral_width(__value, __base);
  302. if (__n > __cap)
  303. return {__last, errc::value_too_large};
  304. __last = __first + __n;
  305. char* __p = __last;
  306. do {
  307. unsigned __c = __value % __base;
  308. __value /= __base;
  309. *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
  310. } while (__value != 0);
  311. return {__last, errc(0)};
  312. }
  313. template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
  314. _LIBCPP_AVAILABILITY_TO_CHARS
  315. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  316. to_chars(char* __first, char* __last, _Tp __value)
  317. {
  318. return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
  319. }
  320. template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
  321. _LIBCPP_AVAILABILITY_TO_CHARS
  322. inline _LIBCPP_INLINE_VISIBILITY to_chars_result
  323. to_chars(char* __first, char* __last, _Tp __value, int __base)
  324. {
  325. _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
  326. return __to_chars_integral(__first, __last, __value, __base,
  327. is_signed<_Tp>());
  328. }
  329. template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
  330. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  331. __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
  332. {
  333. using __tl = numeric_limits<_Tp>;
  334. decltype(__to_unsigned_like(__value)) __x;
  335. bool __neg = (__first != __last && *__first == '-');
  336. auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
  337. switch (__r.ec)
  338. {
  339. case errc::invalid_argument:
  340. return {__first, __r.ec};
  341. case errc::result_out_of_range:
  342. return __r;
  343. default:
  344. break;
  345. }
  346. if (__neg)
  347. {
  348. if (__x <= __complement(__to_unsigned_like(__tl::min())))
  349. {
  350. __x = __complement(__x);
  351. _VSTD::memcpy(&__value, &__x, sizeof(__x));
  352. return __r;
  353. }
  354. }
  355. else
  356. {
  357. if (__x <= __tl::max())
  358. {
  359. __value = __x;
  360. return __r;
  361. }
  362. }
  363. return {__r.ptr, errc::result_out_of_range};
  364. }
  365. template <typename _Tp>
  366. inline _LIBCPP_INLINE_VISIBILITY bool
  367. __in_pattern(_Tp __c)
  368. {
  369. return '0' <= __c && __c <= '9';
  370. }
  371. struct _LIBCPP_HIDDEN __in_pattern_result
  372. {
  373. bool __ok;
  374. int __val;
  375. explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }
  376. };
  377. template <typename _Tp>
  378. inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result
  379. __in_pattern(_Tp __c, int __base)
  380. {
  381. if (__base <= 10)
  382. return {'0' <= __c && __c < '0' + __base, __c - '0'};
  383. else if (__in_pattern(__c))
  384. return {true, __c - '0'};
  385. else if ('a' <= __c && __c < 'a' + __base - 10)
  386. return {true, __c - 'a' + 10};
  387. else
  388. return {'A' <= __c && __c < 'A' + __base - 10, __c - 'A' + 10};
  389. }
  390. template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
  391. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  392. __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
  393. _Ts... __args)
  394. {
  395. auto __find_non_zero = [](_It __first, _It __last) {
  396. for (; __first != __last; ++__first)
  397. if (*__first != '0')
  398. break;
  399. return __first;
  400. };
  401. auto __p = __find_non_zero(__first, __last);
  402. if (__p == __last || !__in_pattern(*__p, __args...))
  403. {
  404. if (__p == __first)
  405. return {__first, errc::invalid_argument};
  406. else
  407. {
  408. __value = 0;
  409. return {__p, {}};
  410. }
  411. }
  412. auto __r = __f(__p, __last, __value, __args...);
  413. if (__r.ec == errc::result_out_of_range)
  414. {
  415. for (; __r.ptr != __last; ++__r.ptr)
  416. {
  417. if (!__in_pattern(*__r.ptr, __args...))
  418. break;
  419. }
  420. }
  421. return __r;
  422. }
  423. template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
  424. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  425. __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
  426. {
  427. using __tx = __itoa::__traits<_Tp>;
  428. using __output_type = typename __tx::type;
  429. return __subject_seq_combinator(
  430. __first, __last, __value,
  431. [](const char* __first, const char* __last,
  432. _Tp& __value) -> from_chars_result {
  433. __output_type __a, __b;
  434. auto __p = __tx::__read(__first, __last, __a, __b);
  435. if (__p == __last || !__in_pattern(*__p))
  436. {
  437. __output_type __m = numeric_limits<_Tp>::max();
  438. if (__m >= __a && __m - __a >= __b)
  439. {
  440. __value = __a + __b;
  441. return {__p, {}};
  442. }
  443. }
  444. return {__p, errc::result_out_of_range};
  445. });
  446. }
  447. template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
  448. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  449. __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
  450. {
  451. using __t = decltype(__to_unsigned_like(__value));
  452. return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
  453. }
  454. template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
  455. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  456. __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
  457. int __base)
  458. {
  459. if (__base == 10)
  460. return __from_chars_atoi(__first, __last, __value);
  461. return __subject_seq_combinator(
  462. __first, __last, __value,
  463. [](const char* __p, const char* __lastx, _Tp& __value,
  464. int __base) -> from_chars_result {
  465. using __tl = numeric_limits<_Tp>;
  466. auto __digits = __tl::digits / log2f(float(__base));
  467. _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
  468. for (int __i = 1; __p != __lastx; ++__i, ++__p)
  469. {
  470. if (auto __c = __in_pattern(*__p, __base))
  471. {
  472. if (__i < __digits - 1)
  473. __a = __a * __base + __c.__val;
  474. else
  475. {
  476. if (!__itoa::__mul_overflowed(__a, __base, __a))
  477. ++__p;
  478. __b = __c.__val;
  479. break;
  480. }
  481. }
  482. else
  483. break;
  484. }
  485. if (__p == __lastx || !__in_pattern(*__p, __base))
  486. {
  487. if (__tl::max() - __a >= __b)
  488. {
  489. __value = __a + __b;
  490. return {__p, {}};
  491. }
  492. }
  493. return {__p, errc::result_out_of_range};
  494. },
  495. __base);
  496. }
  497. template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
  498. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  499. __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
  500. int __base)
  501. {
  502. using __t = decltype(__to_unsigned_like(__value));
  503. return __sign_combinator(__first, __last, __value,
  504. __from_chars_integral<__t>, __base);
  505. }
  506. template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
  507. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  508. from_chars(const char* __first, const char* __last, _Tp& __value)
  509. {
  510. return __from_chars_atoi(__first, __last, __value);
  511. }
  512. template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
  513. inline _LIBCPP_INLINE_VISIBILITY from_chars_result
  514. from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
  515. {
  516. _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
  517. return __from_chars_integral(__first, __last, __value, __base);
  518. }
  519. // Floating-point implementation starts here.
  520. // Unlike the other parts of charconv this is only available in C++17 and newer.
  521. #if _LIBCPP_STD_VER > 14
  522. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  523. to_chars_result to_chars(char* __first, char* __last, float __value);
  524. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  525. to_chars_result to_chars(char* __first, char* __last, double __value);
  526. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  527. to_chars_result to_chars(char* __first, char* __last, long double __value);
  528. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  529. to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt);
  530. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  531. to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt);
  532. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  533. to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt);
  534. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  535. to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision);
  536. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  537. to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision);
  538. _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
  539. to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
  540. # endif // _LIBCPP_STD_VER > 14
  541. #endif // _LIBCPP_CXX03_LANG
  542. _LIBCPP_END_NAMESPACE_STD
  543. _LIBCPP_POP_MACROS
  544. #endif // _LIBCPP_CHARCONV