charconv 20 KB

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