118 items
NAME ↑ SIZE MODIFIED PERMS ACTIONS
.. / Parent Directory
backward — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
bits — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
debug — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
decimal — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
experimental — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
ext — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
parallel — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
pstl — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
tr1 — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
tr2 — dir
2026-06-03 15:44 · rwxr-xr-x
2026-06-03 15:44 rwxr-xr-x
2025-09-15 15:41 · rwxr-xr-x
2025-09-15 15:41 rwxr-xr-x
algorithm — 2.97 KB
2025-09-15 15:41 · rw-r--r--
2.97 KB 2025-09-15 15:41 rw-r--r--
any — 18.32 KB
2025-09-15 15:41 · rw-r--r--
18.32 KB 2025-09-15 15:41 rw-r--r--
array — 13.51 KB
2025-09-15 15:41 · rw-r--r--
13.51 KB 2025-09-15 15:41 rw-r--r--
atomic — 47.66 KB
2025-09-15 15:41 · rw-r--r--
47.66 KB 2025-09-15 15:41 rw-r--r--
barrier — 7.84 KB
2025-09-15 15:41 · rw-r--r--
7.84 KB 2025-09-15 15:41 rw-r--r--
bit — 11.9 KB
2025-09-15 15:41 · rw-r--r--
11.9 KB 2025-09-15 15:41 rw-r--r--
bitset — 44.92 KB
2025-09-15 15:41 · rw-r--r--
44.92 KB 2025-09-15 15:41 rw-r--r--
cassert — 1.61 KB
2025-09-15 15:41 · rw-r--r--
1.61 KB 2025-09-15 15:41 rw-r--r--
ccomplex — 1.3 KB
2025-09-15 15:41 · rw-r--r--
1.3 KB 2025-09-15 15:41 rw-r--r--
cctype — 2.35 KB
2025-09-15 15:41 · rw-r--r--
2.35 KB 2025-09-15 15:41 rw-r--r--
cerrno — 1.73 KB
2025-09-15 15:41 · rw-r--r--
1.73 KB 2025-09-15 15:41 rw-r--r--
cfenv — 2 KB
2025-09-15 15:41 · rw-r--r--
2 KB 2025-09-15 15:41 rw-r--r--
cfloat — 1.84 KB
2025-09-15 15:41 · rw-r--r--
1.84 KB 2025-09-15 15:41 rw-r--r--
charconv — 19.3 KB
2025-09-15 15:41 · rw-r--r--
19.3 KB 2025-09-15 15:41 rw-r--r--
chrono — 94.93 KB
2025-09-15 15:41 · rw-r--r--
94.93 KB 2025-09-15 15:41 rw-r--r--
cinttypes — 2.11 KB
2025-09-15 15:41 · rw-r--r--
2.11 KB 2025-09-15 15:41 rw-r--r--
ciso646 — 1.43 KB
2025-09-15 15:41 · rw-r--r--
1.43 KB 2025-09-15 15:41 rw-r--r--
climits — 1.87 KB
2025-09-15 15:41 · rw-r--r--
1.87 KB 2025-09-15 15:41 rw-r--r--
clocale — 1.86 KB
2025-09-15 15:41 · rw-r--r--
1.86 KB 2025-09-15 15:41 rw-r--r--
cmath — 48.22 KB
2025-09-15 15:41 · rw-r--r--
48.22 KB 2025-09-15 15:41 rw-r--r--
codecvt — 5.15 KB
2025-09-15 15:41 · rw-r--r--
5.15 KB 2025-09-15 15:41 rw-r--r--
compare — 27.61 KB
2025-09-15 15:41 · rw-r--r--
27.61 KB 2025-09-15 15:41 rw-r--r--
complex — 55.37 KB
2025-09-15 15:41 · rw-r--r--
55.37 KB 2025-09-15 15:41 rw-r--r--
complex.h — 1.56 KB
2025-09-15 15:41 · rw-r--r--
1.56 KB 2025-09-15 15:41 rw-r--r--
concepts — 11.94 KB
2025-09-15 15:41 · rw-r--r--
11.94 KB 2025-09-15 15:41 rw-r--r--
condition_variable — 12.48 KB
2025-09-15 15:41 · rw-r--r--
12.48 KB 2025-09-15 15:41 rw-r--r--
coroutine — 8.94 KB
2025-09-15 15:41 · rw-r--r--
8.94 KB 2025-09-15 15:41 rw-r--r--
csetjmp — 1.9 KB
2025-09-15 15:41 · rw-r--r--
1.9 KB 2025-09-15 15:41 rw-r--r--
csignal — 1.81 KB
2025-09-15 15:41 · rw-r--r--
1.81 KB 2025-09-15 15:41 rw-r--r--
cstdalign — 1.37 KB
2025-09-15 15:41 · rw-r--r--
1.37 KB 2025-09-15 15:41 rw-r--r--
cstdarg — 1.82 KB
2025-09-15 15:41 · rw-r--r--
1.82 KB 2025-09-15 15:41 rw-r--r--
cstdbool — 1.37 KB
2025-09-15 15:41 · rw-r--r--
1.37 KB 2025-09-15 15:41 rw-r--r--
cstddef — 6.53 KB
2025-09-15 15:41 · rw-r--r--
6.53 KB 2025-09-15 15:41 rw-r--r--
cstdint — 2.28 KB
2025-09-15 15:41 · rw-r--r--
2.28 KB 2025-09-15 15:41 rw-r--r--
cstdio — 4.33 KB
2025-09-15 15:41 · rw-r--r--
4.33 KB 2025-09-15 15:41 rw-r--r--
cstdlib — 6.18 KB
2025-09-15 15:41 · rw-r--r--
6.18 KB 2025-09-15 15:41 rw-r--r--
cstring — 3.08 KB
2025-09-15 15:41 · rw-r--r--
3.08 KB 2025-09-15 15:41 rw-r--r--
ctgmath — 1.33 KB
2025-09-15 15:41 · rw-r--r--
1.33 KB 2025-09-15 15:41 rw-r--r--
ctime — 2.24 KB
2025-09-15 15:41 · rw-r--r--
2.24 KB 2025-09-15 15:41 rw-r--r--
cuchar — 2.16 KB
2025-09-15 15:41 · rw-r--r--
2.16 KB 2025-09-15 15:41 rw-r--r--
cwchar — 6.39 KB
2025-09-15 15:41 · rw-r--r--
6.39 KB 2025-09-15 15:41 rw-r--r--
cwctype — 2.73 KB
2025-09-15 15:41 · rw-r--r--
2.73 KB 2025-09-15 15:41 rw-r--r--
cxxabi.h — 21.76 KB
2025-09-15 15:41 · rw-r--r--
21.76 KB 2025-09-15 15:41 rw-r--r--
deque — 3.88 KB
2025-09-15 15:41 · rw-r--r--
3.88 KB 2025-09-15 15:41 rw-r--r--
exception — 4.9 KB
2025-09-15 15:41 · rw-r--r--
4.9 KB 2025-09-15 15:41 rw-r--r--
execution — 1.76 KB
2025-09-15 15:41 · rw-r--r--
1.76 KB 2025-09-15 15:41 rw-r--r--
fenv.h — 1.97 KB
2025-09-15 15:41 · rw-r--r--
1.97 KB 2025-09-15 15:41 rw-r--r--
filesystem — 1.61 KB
2025-09-15 15:41 · rw-r--r--
1.61 KB 2025-09-15 15:41 rw-r--r--
forward_list — 2.63 KB
2025-09-15 15:41 · rw-r--r--
2.63 KB 2025-09-15 15:41 rw-r--r--
fstream — 39.73 KB
2025-09-15 15:41 · rw-r--r--
39.73 KB 2025-09-15 15:41 rw-r--r--
functional — 39.26 KB
2025-09-15 15:41 · rw-r--r--
39.26 KB 2025-09-15 15:41 rw-r--r--
future — 51.05 KB
2025-09-15 15:41 · rw-r--r--
51.05 KB 2025-09-15 15:41 rw-r--r--
initializer_list — 2.97 KB
2025-09-15 15:41 · rw-r--r--
2.97 KB 2025-09-15 15:41 rw-r--r--
iomanip — 16.16 KB
2025-09-15 15:41 · rw-r--r--
16.16 KB 2025-09-15 15:41 rw-r--r--
ios — 1.56 KB
2025-09-15 15:41 · rw-r--r--
1.56 KB 2025-09-15 15:41 rw-r--r--
iosfwd — 7.34 KB
2025-09-15 15:41 · rw-r--r--
7.34 KB 2025-09-15 15:41 rw-r--r--
iostream — 2.63 KB
2025-09-15 15:41 · rw-r--r--
2.63 KB 2025-09-15 15:41 rw-r--r--
istream — 33.3 KB
2025-09-15 15:41 · rw-r--r--
33.3 KB 2025-09-15 15:41 rw-r--r--
iterator — 2.69 KB
2025-09-15 15:41 · rw-r--r--
2.69 KB 2025-09-15 15:41 rw-r--r--
latch — 2.67 KB
2025-09-15 15:41 · rw-r--r--
2.67 KB 2025-09-15 15:41 rw-r--r--
limits — 69.99 KB
2025-09-15 15:41 · rw-r--r--
69.99 KB 2025-09-15 15:41 rw-r--r--
list — 3.57 KB
2025-09-15 15:41 · rw-r--r--
3.57 KB 2025-09-15 15:41 rw-r--r--
locale — 1.45 KB
2025-09-15 15:41 · rw-r--r--
1.45 KB 2025-09-15 15:41 rw-r--r--
map — 3.84 KB
2025-09-15 15:41 · rw-r--r--
3.84 KB 2025-09-15 15:41 rw-r--r--
math.h — 4.47 KB
2025-09-15 15:41 · rw-r--r--
4.47 KB 2025-09-15 15:41 rw-r--r--
memory — 4.41 KB
2025-09-15 15:41 · rw-r--r--
4.41 KB 2025-09-15 15:41 rw-r--r--
memory_resource — 20.62 KB
2025-09-15 15:41 · rw-r--r--
20.62 KB 2025-09-15 15:41 rw-r--r--
mutex — 23.66 KB
2025-09-15 15:41 · rw-r--r--
23.66 KB 2025-09-15 15:41 rw-r--r--
new — 8.15 KB
2025-09-15 15:41 · rw-r--r--
8.15 KB 2025-09-15 15:41 rw-r--r--
numbers — 6.07 KB
2025-09-15 15:41 · rw-r--r--
6.07 KB 2025-09-15 15:41 rw-r--r--
numeric — 25.5 KB
2025-09-15 15:41 · rw-r--r--
25.5 KB 2025-09-15 15:41 rw-r--r--
optional — 39.23 KB
2025-09-15 15:41 · rw-r--r--
39.23 KB 2025-09-15 15:41 rw-r--r--
ostream — 25.37 KB
2025-09-15 15:41 · rw-r--r--
25.37 KB 2025-09-15 15:41 rw-r--r--
queue — 2.41 KB
2025-09-15 15:41 · rw-r--r--
2.41 KB 2025-09-15 15:41 rw-r--r--
random — 1.65 KB
2025-09-15 15:41 · rw-r--r--
1.65 KB 2025-09-15 15:41 rw-r--r--
ranges — 104.69 KB
2025-09-15 15:41 · rw-r--r--
104.69 KB 2025-09-15 15:41 rw-r--r--
ratio — 19.64 KB
2025-09-15 15:41 · rw-r--r--
19.64 KB 2025-09-15 15:41 rw-r--r--
regex — 2.79 KB
2025-09-15 15:41 · rw-r--r--
2.79 KB 2025-09-15 15:41 rw-r--r--
scoped_allocator — 17.24 KB
2025-09-15 15:41 · rw-r--r--
17.24 KB 2025-09-15 15:41 rw-r--r--
semaphore — 2.93 KB
2025-09-15 15:41 · rw-r--r--
2.93 KB 2025-09-15 15:41 rw-r--r--
set — 3.71 KB
2025-09-15 15:41 · rw-r--r--
3.71 KB 2025-09-15 15:41 rw-r--r--
shared_mutex — 24.01 KB
2025-09-15 15:41 · rw-r--r--
24.01 KB 2025-09-15 15:41 rw-r--r--
source_location — 2.68 KB
2025-09-15 15:41 · rw-r--r--
2.68 KB 2025-09-15 15:41 rw-r--r--
span — 12.82 KB
2025-09-15 15:41 · rw-r--r--
12.82 KB 2025-09-15 15:41 rw-r--r--
sstream — 38.31 KB
2025-09-15 15:41 · rw-r--r--
38.31 KB 2025-09-15 15:41 rw-r--r--
stack — 2.33 KB
2025-09-15 15:41 · rw-r--r--
2.33 KB 2025-09-15 15:41 rw-r--r--
stdexcept — 9.65 KB
2025-09-15 15:41 · rw-r--r--
9.65 KB 2025-09-15 15:41 rw-r--r--
stdlib.h — 2.2 KB
2025-09-15 15:41 · rw-r--r--
2.2 KB 2025-09-15 15:41 rw-r--r--
stop_token — 15.61 KB
2025-09-15 15:41 · rw-r--r--
15.61 KB 2025-09-15 15:41 rw-r--r--
streambuf — 29.19 KB
2025-09-15 15:41 · rw-r--r--
29.19 KB 2025-09-15 15:41 rw-r--r--
string — 4.54 KB
2025-09-15 15:41 · rw-r--r--
4.54 KB 2025-09-15 15:41 rw-r--r--
string_view — 25.59 KB
2025-09-15 15:41 · rw-r--r--
25.59 KB 2025-09-15 15:41 rw-r--r--
syncstream — 8.13 KB
2025-09-15 15:41 · rw-r--r--
8.13 KB 2025-09-15 15:41 rw-r--r--
system_error — 14.65 KB
2025-09-15 15:41 · rw-r--r--
14.65 KB 2025-09-15 15:41 rw-r--r--
tgmath.h — 1.33 KB
2025-09-15 15:41 · rw-r--r--
1.33 KB 2025-09-15 15:41 rw-r--r--
thread — 5.78 KB
2025-09-15 15:41 · rw-r--r--
5.78 KB 2025-09-15 15:41 rw-r--r--
tuple — 61.71 KB
2025-09-15 15:41 · rw-r--r--
61.71 KB 2025-09-15 15:41 rw-r--r--
type_traits — 105.12 KB
2025-09-15 15:41 · rw-r--r--
105.12 KB 2025-09-15 15:41 rw-r--r--
typeindex — 3.43 KB
2025-09-15 15:41 · rw-r--r--
3.43 KB 2025-09-15 15:41 rw-r--r--
typeinfo — 7.56 KB
2025-09-15 15:41 · rw-r--r--
7.56 KB 2025-09-15 15:41 rw-r--r--
unordered_map — 3.39 KB
2025-09-15 15:41 · rw-r--r--
3.39 KB 2025-09-15 15:41 rw-r--r--
unordered_set — 3.26 KB
2025-09-15 15:41 · rw-r--r--
3.26 KB 2025-09-15 15:41 rw-r--r--
utility — 14.48 KB
2025-09-15 15:41 · rw-r--r--
14.48 KB 2025-09-15 15:41 rw-r--r--
valarray — 39.74 KB
2025-09-15 15:41 · rw-r--r--
39.74 KB 2025-09-15 15:41 rw-r--r--
variant — 61.39 KB
2025-09-15 15:41 · rw-r--r--
61.39 KB 2025-09-15 15:41 rw-r--r--
vector — 4.17 KB
2025-09-15 15:41 · rw-r--r--
4.17 KB 2025-09-15 15:41 rw-r--r--
version — 9.05 KB
2025-09-15 15:41 · rw-r--r--
9.05 KB 2025-09-15 15:41 rw-r--r--
ONLINE
11
118 items
11:22:20
TERMINAL FM
Edit
Preview
Download
Rename
Copy
Chmod
Delete
// Primitive numeric conversions (to_chars and from_chars) -*- C++ -*- // Copyright (C) 2017-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/charconv * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_CHARCONV #define _GLIBCXX_CHARCONV 1 #pragma GCC system_header // As an extension we support in C++14, but this header should not // be included by any other library headers in C++14 mode. This ensures that // the names defined in this header are not added to namespace std unless a // user explicitly includes in C++14 code. #if __cplusplus >= 201402L #include #include // for __bit_width #include // for __to_chars_len, __to_chars_10_impl #include // for std::errc #include #if _GLIBCXX_HAVE_USELOCALE # define __cpp_lib_to_chars 201611L #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Result type of std::to_chars struct to_chars_result { char* ptr; errc ec; #if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L friend bool operator==(const to_chars_result&, const to_chars_result&) = default; #endif }; /// Result type of std::from_chars struct from_chars_result { const char* ptr; errc ec; #if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L friend bool operator==(const from_chars_result&, const from_chars_result&) = default; #endif }; namespace __detail { template using __integer_to_chars_result_type = enable_if_t<__or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>, is_same>>::value, to_chars_result>; // Pick an unsigned type of suitable size. This is used to reduce the // number of specializations of __to_chars_len, __to_chars etc. that // get instantiated. For example, to_chars and to_chars // and to_chars will all use the same code, and so will // to_chars when sizeof(int) == sizeof(long). template struct __to_chars_unsigned_type : __make_unsigned_selector_base { using _UInts = _List; using type = typename __select::__type; }; template using __unsigned_least_t = typename __to_chars_unsigned_type<_Tp>::type; // Generic implementation for arbitrary bases. // Defined in . template constexpr unsigned __to_chars_len(_Tp __value, int __base /* = 10 */) noexcept; template constexpr unsigned __to_chars_len_2(_Tp __value) noexcept { return std::__bit_width(__value); } // Generic implementation for arbitrary bases. template to_chars_result __to_chars(char* __first, char* __last, _Tp __val, int __base) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); to_chars_result __res; const unsigned __len = __to_chars_len(__val, __base); if (__builtin_expect((__last - __first) < __len, 0)) { __res.ptr = __last; __res.ec = errc::value_too_large; return __res; } unsigned __pos = __len - 1; static constexpr char __digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; while (__val >= (unsigned)__base) { auto const __quo = __val / __base; auto const __rem = __val % __base; __first[__pos--] = __digits[__rem]; __val = __quo; } *__first = __digits[__val]; __res.ptr = __first + __len; __res.ec = {}; return __res; } template __integer_to_chars_result_type<_Tp> __to_chars_16(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); to_chars_result __res; const unsigned __len = (__to_chars_len_2(__val) + 3) / 4; if (__builtin_expect((__last - __first) < __len, 0)) { __res.ptr = __last; __res.ec = errc::value_too_large; return __res; } static constexpr char __digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; unsigned __pos = __len - 1; while (__val >= 0x100) { auto __num = __val & 0xF; __val >>= 4; __first[__pos] = __digits[__num]; __num = __val & 0xF; __val >>= 4; __first[__pos - 1] = __digits[__num]; __pos -= 2; } if (__val >= 0x10) { const auto __num = __val & 0xF; __val >>= 4; __first[1] = __digits[__num]; __first[0] = __digits[__val]; } else __first[0] = __digits[__val]; __res.ptr = __first + __len; __res.ec = {}; return __res; } template inline __integer_to_chars_result_type<_Tp> __to_chars_10(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); to_chars_result __res; const unsigned __len = __to_chars_len(__val, 10); if (__builtin_expect((__last - __first) < __len, 0)) { __res.ptr = __last; __res.ec = errc::value_too_large; return __res; } __detail::__to_chars_10_impl(__first, __len, __val); __res.ptr = __first + __len; __res.ec = {}; return __res; } template __integer_to_chars_result_type<_Tp> __to_chars_8(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); to_chars_result __res; unsigned __len = 0; if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Tp>::__digits <= 16) { __len = __val > 077777u ? 6u : __val > 07777u ? 5u : __val > 0777u ? 4u : __val > 077u ? 3u : __val > 07u ? 2u : 1u; } else __len = (__to_chars_len_2(__val) + 2) / 3; if (__builtin_expect((__last - __first) < __len, 0)) { __res.ptr = __last; __res.ec = errc::value_too_large; return __res; } unsigned __pos = __len - 1; while (__val >= 0100) { auto __num = __val & 7; __val >>= 3; __first[__pos] = '0' + __num; __num = __val & 7; __val >>= 3; __first[__pos - 1] = '0' + __num; __pos -= 2; } if (__val >= 010) { auto const __num = __val & 7; __val >>= 3; __first[1] = '0' + __num; __first[0] = '0' + __val; } else __first[0] = '0' + __val; __res.ptr = __first + __len; __res.ec = {}; return __res; } template __integer_to_chars_result_type<_Tp> __to_chars_2(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); to_chars_result __res; const unsigned __len = __to_chars_len_2(__val); if (__builtin_expect((__last - __first) < __len, 0)) { __res.ptr = __last; __res.ec = errc::value_too_large; return __res; } unsigned __pos = __len - 1; while (__pos) { __first[__pos--] = '0' + (__val & 1); __val >>= 1; } // First digit is always '1' because __to_chars_len_2 skips // leading zero bits and std::to_chars handles zero values // directly. __first[0] = '1'; __res.ptr = __first + __len; __res.ec = {}; return __res; } } // namespace __detail template __detail::__integer_to_chars_result_type<_Tp> __to_chars_i(char* __first, char* __last, _Tp __value, int __base = 10) { __glibcxx_assert(2 <= __base && __base <= 36); using _Up = __detail::__unsigned_least_t<_Tp>; _Up __unsigned_val = __value; if (__first == __last) [[__unlikely__]] return { __last, errc::value_too_large }; if (__value == 0) { *__first = '0'; return { __first + 1, errc{} }; } else if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) if (__value < 0) { *__first++ = '-'; __unsigned_val = _Up(~__value) + _Up(1); } switch (__base) { case 16: return __detail::__to_chars_16(__first, __last, __unsigned_val); case 10: return __detail::__to_chars_10(__first, __last, __unsigned_val); case 8: return __detail::__to_chars_8(__first, __last, __unsigned_val); case 2: return __detail::__to_chars_2(__first, __last, __unsigned_val); default: return __detail::__to_chars(__first, __last, __unsigned_val, __base); } } #define _GLIBCXX_TO_CHARS(T) \ inline to_chars_result \ to_chars(char* __first, char* __last, T __value, int __base = 10) \ { return std::__to_chars_i(__first, __last, __value, __base); } _GLIBCXX_TO_CHARS(char) _GLIBCXX_TO_CHARS(signed char) _GLIBCXX_TO_CHARS(unsigned char) _GLIBCXX_TO_CHARS(signed short) _GLIBCXX_TO_CHARS(unsigned short) _GLIBCXX_TO_CHARS(signed int) _GLIBCXX_TO_CHARS(unsigned int) _GLIBCXX_TO_CHARS(signed long) _GLIBCXX_TO_CHARS(unsigned long) _GLIBCXX_TO_CHARS(signed long long) _GLIBCXX_TO_CHARS(unsigned long long) #if defined(__GLIBCXX_TYPE_INT_N_0) _GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_0) _GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_0) #endif #if defined(__GLIBCXX_TYPE_INT_N_1) _GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_1) _GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_1) #endif #if defined(__GLIBCXX_TYPE_INT_N_2) _GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_2) _GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_2) #endif #if defined(__GLIBCXX_TYPE_INT_N_3) _GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_3) _GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_3) #endif #undef _GLIBCXX_TO_CHARS // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3266. to_chars(bool) should be deleted to_chars_result to_chars(char*, char*, bool, int = 10) = delete; namespace __detail { template bool __raise_and_add(_Tp& __val, int __base, unsigned char __c) { if (__builtin_mul_overflow(__val, __base, &__val) || __builtin_add_overflow(__val, __c, &__val)) return false; return true; } /// std::from_chars implementation for integers in base 2. template bool __from_chars_binary(const char*& __first, const char* __last, _Tp& __val) { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); const ptrdiff_t __len = __last - __first; ptrdiff_t __i = 0; while (__i < __len && __first[__i] == '0') ++__i; const ptrdiff_t __leading_zeroes = __i; while (__i < __len) { const unsigned char __c = (unsigned)__first[__i] - '0'; if (__c < 2) __val = (__val << 1) | __c; else break; __i++; } __first += __i; return (__i - __leading_zeroes) <= __gnu_cxx::__int_traits<_Tp>::__digits; } /// std::from_chars implementation for integers in bases 3 to 10. template bool __from_chars_digit(const char*& __first, const char* __last, _Tp& __val, int __base) { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); auto __matches = [__base](char __c) { return '0' <= __c && __c <= ('0' + (__base - 1)); }; while (__first != __last) { const char __c = *__first; if (__matches(__c)) { if (!__raise_and_add(__val, __base, __c - '0')) { while (++__first != __last && __matches(*__first)) ; return false; } __first++; } else return true; } return true; } constexpr char __from_chars_alpha_to_num(char __c) { switch (__c) { case 'a': case 'A': return 10; case 'b': case 'B': return 11; case 'c': case 'C': return 12; case 'd': case 'D': return 13; case 'e': case 'E': return 14; case 'f': case 'F': return 15; case 'g': case 'G': return 16; case 'h': case 'H': return 17; case 'i': case 'I': return 18; case 'j': case 'J': return 19; case 'k': case 'K': return 20; case 'l': case 'L': return 21; case 'm': case 'M': return 22; case 'n': case 'N': return 23; case 'o': case 'O': return 24; case 'p': case 'P': return 25; case 'q': case 'Q': return 26; case 'r': case 'R': return 27; case 's': case 'S': return 28; case 't': case 'T': return 29; case 'u': case 'U': return 30; case 'v': case 'V': return 31; case 'w': case 'W': return 32; case 'x': case 'X': return 33; case 'y': case 'Y': return 34; case 'z': case 'Z': return 35; } return 127; } /// std::from_chars implementation for integers in bases 11 to 36. template bool __from_chars_alnum(const char*& __first, const char* __last, _Tp& __val, int __base) { bool __valid = true; while (__first != __last) { char __c = *__first; if ('0' <= __c && __c <= '9') // isdigit __c -= '0'; else { __c = __from_chars_alpha_to_num(__c); if (__c >= __base) break; } if (__builtin_expect(__valid, 1)) __valid = __raise_and_add(__val, __base, __c); __first++; } return __valid; } template using __integer_from_chars_result_type = enable_if_t<__or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>, is_same>>::value, from_chars_result>; } // namespace __detail /// std::from_chars for integral types. template __detail::__integer_from_chars_result_type<_Tp> from_chars(const char* __first, const char* __last, _Tp& __value, int __base = 10) { __glibcxx_assert(2 <= __base && __base <= 36); from_chars_result __res{__first, {}}; int __sign = 1; if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) if (__first != __last && *__first == '-') { __sign = -1; ++__first; } using _Up = __detail::__unsigned_least_t<_Tp>; _Up __val = 0; const auto __start = __first; bool __valid; if (__base == 2) __valid = __detail::__from_chars_binary(__first, __last, __val); else if (__base <= 10) __valid = __detail::__from_chars_digit(__first, __last, __val, __base); else __valid = __detail::__from_chars_alnum(__first, __last, __val, __base); if (__builtin_expect(__first == __start, 0)) __res.ec = errc::invalid_argument; else { __res.ptr = __first; if (!__valid) __res.ec = errc::result_out_of_range; else { if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) { _Tp __tmp; if (__builtin_mul_overflow(__val, __sign, &__tmp)) __res.ec = errc::result_out_of_range; else __value = __tmp; } else { if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Up>::__max > __gnu_cxx::__int_traits<_Tp>::__max) { if (__val > __gnu_cxx::__int_traits<_Tp>::__max) __res.ec = errc::result_out_of_range; else __value = __val; } else __value = __val; } } } return __res; } /// floating-point format for primitive numerical conversion enum class chars_format { scientific = 1, fixed = 2, hex = 4, general = fixed | scientific }; constexpr chars_format operator|(chars_format __lhs, chars_format __rhs) noexcept { return (chars_format)((unsigned)__lhs | (unsigned)__rhs); } constexpr chars_format operator&(chars_format __lhs, chars_format __rhs) noexcept { return (chars_format)((unsigned)__lhs & (unsigned)__rhs); } constexpr chars_format operator^(chars_format __lhs, chars_format __rhs) noexcept { return (chars_format)((unsigned)__lhs ^ (unsigned)__rhs); } constexpr chars_format operator~(chars_format __fmt) noexcept { return (chars_format)~(unsigned)__fmt; } constexpr chars_format& operator|=(chars_format& __lhs, chars_format __rhs) noexcept { return __lhs = __lhs | __rhs; } constexpr chars_format& operator&=(chars_format& __lhs, chars_format __rhs) noexcept { return __lhs = __lhs & __rhs; } constexpr chars_format& operator^=(chars_format& __lhs, chars_format __rhs) noexcept { return __lhs = __lhs ^ __rhs; } #if _GLIBCXX_HAVE_USELOCALE from_chars_result from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) noexcept; from_chars_result from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) noexcept; from_chars_result from_chars(const char* __first, const char* __last, long double& __value, chars_format __fmt = chars_format::general) noexcept; #endif #if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \ && __SIZE_WIDTH__ >= 32 // Floating-point std::to_chars // Overloads for float. to_chars_result to_chars(char* __first, char* __last, float __value) noexcept; to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) noexcept; to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) noexcept; // Overloads for double. to_chars_result to_chars(char* __first, char* __last, double __value) noexcept; to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) noexcept; to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) noexcept; // Overloads for long double. to_chars_result to_chars(char* __first, char* __last, long double __value) noexcept; to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) noexcept; to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) noexcept; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_CHARCONV