Skip to content

Commit 5c1188d

Browse files
authored
Revert "[libc++] Optimize num_put integral functions (#120859)"
This reverts commit 15edf87.
1 parent 1e89a76 commit 5c1188d

File tree

13 files changed

+149
-209
lines changed

13 files changed

+149
-209
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ Improvements and New Features
120120

121121
- Added :ref:`hardening mode <hardening>` support for ``forward_list`` and ``bitset``.
122122

123-
- The ``num_get::do_put`` integral overloads have been optimized, resulting in a performance improvement of up to 2.4x.
124-
125123
Deprecations and Removals
126124
-------------------------
127125

libcxx/include/__charconv/tables.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919

2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

22+
#if _LIBCPP_STD_VER >= 17
23+
2224
namespace __itoa {
2325

24-
inline _LIBCPP_CONSTEXPR const char __base_2_lut[64] = {
26+
inline constexpr char __base_2_lut[64] = {
2527
'0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
2628
'0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
2729
'1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
2830

29-
inline _LIBCPP_CONSTEXPR const char __base_8_lut[128] = {
31+
inline constexpr char __base_8_lut[128] = {
3032
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
3133
'1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
3234
'2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
3335
'4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3',
3436
'5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
3537
'6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
3638

37-
inline _LIBCPP_CONSTEXPR const char __base_16_lut[512] = {
39+
inline constexpr char __base_16_lut[512] = {
3840
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
3941
'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
4042
'1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
@@ -59,7 +61,7 @@ inline _LIBCPP_CONSTEXPR const char __base_16_lut[512] = {
5961
'1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
6062
'f', 'd', 'f', 'e', 'f', 'f'};
6163

62-
inline _LIBCPP_CONSTEXPR const uint32_t __pow10_32[10] = {
64+
inline constexpr uint32_t __pow10_32[10] = {
6365
UINT32_C(0),
6466
UINT32_C(10),
6567
UINT32_C(100),
@@ -71,7 +73,7 @@ inline _LIBCPP_CONSTEXPR const uint32_t __pow10_32[10] = {
7173
UINT32_C(100000000),
7274
UINT32_C(1000000000)};
7375

74-
inline _LIBCPP_CONSTEXPR const uint64_t __pow10_64[20] = {
76+
inline constexpr uint64_t __pow10_64[20] = {
7577
UINT64_C(0),
7678
UINT64_C(10),
7779
UINT64_C(100),
@@ -94,8 +96,8 @@ inline _LIBCPP_CONSTEXPR const uint64_t __pow10_64[20] = {
9496
UINT64_C(10000000000000000000)};
9597

9698
# if _LIBCPP_HAS_INT128
97-
inline _LIBCPP_CONSTEXPR const int __pow10_128_offset = 0;
98-
inline _LIBCPP_CONSTEXPR const __uint128_t __pow10_128[40] = {
99+
inline constexpr int __pow10_128_offset = 0;
100+
inline constexpr __uint128_t __pow10_128[40] = {
99101
UINT64_C(0),
100102
UINT64_C(10),
101103
UINT64_C(100),
@@ -138,7 +140,7 @@ inline _LIBCPP_CONSTEXPR const __uint128_t __pow10_128[40] = {
138140
(__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
139141
# endif
140142

141-
inline _LIBCPP_CONSTEXPR const char __digits_base_10[200] = {
143+
inline constexpr char __digits_base_10[200] = {
142144
// clang-format off
143145
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
144146
'1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
@@ -154,6 +156,8 @@ inline _LIBCPP_CONSTEXPR const char __digits_base_10[200] = {
154156

155157
} // namespace __itoa
156158

159+
#endif // _LIBCPP_STD_VER >= 17
160+
157161
_LIBCPP_END_NAMESPACE_STD
158162

159163
#endif // _LIBCPP___CHARCONV_TABLES

libcxx/include/__charconv/to_chars_base_10.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,53 +26,55 @@ _LIBCPP_PUSH_MACROS
2626

2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

29+
#if _LIBCPP_STD_VER >= 17
30+
2931
namespace __itoa {
3032

31-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) _NOEXCEPT {
33+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
3234
*__first = '0' + static_cast<char>(__value);
3335
return __first + 1;
3436
}
3537

36-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) _NOEXCEPT {
38+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
3739
return std::copy_n(&__digits_base_10[__value * 2], 2, __first);
3840
}
3941

40-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) _NOEXCEPT {
42+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
4143
return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
4244
}
4345

44-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) _NOEXCEPT {
46+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
4547
return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
4648
}
4749

48-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) _NOEXCEPT {
50+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
4951
return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
5052
}
5153

52-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) _NOEXCEPT {
54+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
5355
return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
5456
}
5557

56-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) _NOEXCEPT {
58+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
5759
return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
5860
}
5961

60-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) _NOEXCEPT {
62+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
6163
return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
6264
}
6365

64-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) _NOEXCEPT {
66+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
6567
return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
6668
}
6769

6870
template <class _Tp>
69-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) _NOEXCEPT {
71+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
7072
return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
7173
static_cast<uint32_t>(__value % 100000000));
7274
}
7375

7476
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
75-
__base_10_u32(char* __first, uint32_t __value) _NOEXCEPT {
77+
__base_10_u32(char* __first, uint32_t __value) noexcept {
7678
if (__value < 1000000) {
7779
if (__value < 10000) {
7880
if (__value < 100) {
@@ -108,7 +110,7 @@ __base_10_u32(char* __first, uint32_t __value) _NOEXCEPT {
108110
}
109111

110112
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
111-
__base_10_u64(char* __buffer, uint64_t __value) _NOEXCEPT {
113+
__base_10_u64(char* __buffer, uint64_t __value) noexcept {
112114
if (__value <= UINT32_MAX)
113115
return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
114116

@@ -130,13 +132,13 @@ __base_10_u64(char* __buffer, uint64_t __value) _NOEXCEPT {
130132
/// \note The lookup table contains a partial set of exponents limiting the
131133
/// range that can be used. However the range is sufficient for
132134
/// \ref __base_10_u128.
133-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) _NOEXCEPT {
135+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
134136
_LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds");
135137
return __pow10_128[__exp - __pow10_128_offset];
136138
}
137139

138140
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
139-
__base_10_u128(char* __buffer, __uint128_t __value) _NOEXCEPT {
141+
__base_10_u128(char* __buffer, __uint128_t __value) noexcept {
140142
_LIBCPP_ASSERT_INTERNAL(
141143
__value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true.");
142144

@@ -177,6 +179,8 @@ __base_10_u128(char* __buffer, __uint128_t __value) _NOEXCEPT {
177179
# endif
178180
} // namespace __itoa
179181

182+
#endif // _LIBCPP_STD_VER >= 17
183+
180184
_LIBCPP_END_NAMESPACE_STD
181185

182186
_LIBCPP_POP_MACROS

libcxx/include/__charconv/to_chars_integral.h

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ _LIBCPP_PUSH_MACROS
3939

4040
_LIBCPP_BEGIN_NAMESPACE_STD
4141

42+
#if _LIBCPP_STD_VER >= 17
43+
44+
to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
45+
4246
template <typename _Tp>
43-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
47+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
4448
__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type);
4549

4650
template <typename _Tp>
47-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
51+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
4852
__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {
4953
auto __x = std::__to_unsigned_like(__value);
5054
if (__value < 0 && __first != __last) {
@@ -56,7 +60,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {
5660
}
5761

5862
template <typename _Tp>
59-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
63+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
6064
__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
6165
using __tx = __itoa::__traits<_Tp>;
6266
auto __diff = __last - __first;
@@ -69,7 +73,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
6973

7074
# if _LIBCPP_HAS_INT128
7175
template <>
72-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
76+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
7377
__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
7478
// When the value fits in 64-bits use the 64-bit code path. This reduces
7579
// the number of expensive calculations on 128-bit values.
@@ -88,20 +92,20 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
8892
}
8993
# endif
9094

91-
template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> = 0>
92-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
93-
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base);
95+
template <class _Tp>
96+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
97+
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type);
9498

95-
template <class _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0>
96-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
97-
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base) {
99+
template <typename _Tp>
100+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
101+
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, true_type) {
98102
auto __x = std::__to_unsigned_like(__value);
99103
if (__value < 0 && __first != __last) {
100104
*__first++ = '-';
101105
__x = std::__complement(__x);
102106
}
103107

104-
return std::__to_chars_integral(__first, __last, __x, __base);
108+
return std::__to_chars_integral(__first, __last, __x, __base, false_type());
105109
}
106110

107111
namespace __itoa {
@@ -112,15 +116,15 @@ struct _LIBCPP_HIDDEN __integral;
112116
template <>
113117
struct _LIBCPP_HIDDEN __integral<2> {
114118
template <typename _Tp>
115-
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
119+
_LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
116120
// If value == 0 still need one digit. If the value != this has no
117121
// effect since the code scans for the most significant bit set. (Note
118122
// that __libcpp_clz doesn't work for 0.)
119123
return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1);
120124
}
121125

122126
template <typename _Tp>
123-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
127+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result
124128
__to_chars(char* __first, char* __last, _Tp __value) {
125129
ptrdiff_t __cap = __last - __first;
126130
int __n = __width(__value);
@@ -148,15 +152,15 @@ struct _LIBCPP_HIDDEN __integral<2> {
148152
template <>
149153
struct _LIBCPP_HIDDEN __integral<8> {
150154
template <typename _Tp>
151-
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
155+
_LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
152156
// If value == 0 still need one digit. If the value != this has no
153157
// effect since the code scans for the most significat bit set. (Note
154158
// that __libcpp_clz doesn't work for 0.)
155159
return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3;
156160
}
157161

158162
template <typename _Tp>
159-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
163+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result
160164
__to_chars(char* __first, char* __last, _Tp __value) {
161165
ptrdiff_t __cap = __last - __first;
162166
int __n = __width(__value);
@@ -184,15 +188,15 @@ struct _LIBCPP_HIDDEN __integral<8> {
184188
template <>
185189
struct _LIBCPP_HIDDEN __integral<16> {
186190
template <typename _Tp>
187-
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
191+
_LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
188192
// If value == 0 still need one digit. If the value != this has no
189193
// effect since the code scans for the most significat bit set. (Note
190194
// that __libcpp_clz doesn't work for 0.)
191195
return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4;
192196
}
193197

194198
template <typename _Tp>
195-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
199+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result
196200
__to_chars(char* __first, char* __last, _Tp __value) {
197201
ptrdiff_t __cap = __last - __first;
198202
int __n = __width(__value);
@@ -231,13 +235,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt
231235
}
232236

233237
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0>
234-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
238+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
235239
__to_chars_integral(char* __first, char* __last, _Tp __value) {
236240
return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
237241
}
238242

239243
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0>
240-
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
244+
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
241245
__to_chars_integral(char* __first, char* __last, _Tp __value) {
242246
return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
243247
}
@@ -268,9 +272,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt
268272
__libcpp_unreachable();
269273
}
270274

271-
template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> >
272-
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
273-
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base) {
275+
template <typename _Tp>
276+
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
277+
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) {
274278
if (__base == 10) [[likely]]
275279
return std::__to_chars_itoa(__first, __last, __value, false_type());
276280

@@ -298,28 +302,6 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base) {
298302
return {__last, errc(0)};
299303
}
300304

301-
_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 char __hex_to_upper(char __c) {
302-
switch (__c) {
303-
case 'a':
304-
return 'A';
305-
case 'b':
306-
return 'B';
307-
case 'c':
308-
return 'C';
309-
case 'd':
310-
return 'D';
311-
case 'e':
312-
return 'E';
313-
case 'f':
314-
return 'F';
315-
}
316-
return __c;
317-
}
318-
319-
#if _LIBCPP_STD_VER >= 17
320-
321-
to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
322-
323305
template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
324306
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
325307
to_chars(char* __first, char* __last, _Tp __value) {
@@ -334,7 +316,7 @@ to_chars(char* __first, char* __last, _Tp __value, int __base) {
334316
_LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]");
335317

336318
using _Type = __make_32_64_or_128_bit_t<_Tp>;
337-
return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base);
319+
return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>());
338320
}
339321

340322
#endif // _LIBCPP_STD_VER >= 17

libcxx/include/__charconv/to_chars_result.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {
3434

3535
#endif // _LIBCPP_STD_VER >= 17
3636

37-
struct __to_chars_result {
38-
char* __ptr;
39-
errc __ec;
40-
41-
#if _LIBCPP_STD_VER >= 17
42-
_LIBCPP_HIDE_FROM_ABI constexpr operator to_chars_result() { return {__ptr, __ec}; }
43-
#endif
44-
};
45-
4637
_LIBCPP_END_NAMESPACE_STD
4738

4839
#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H

0 commit comments

Comments
 (0)