Mercurial > hg > CbC > CbC_llvm
comparison libcxx/include/charconv @ 173:0572611fdcc8 llvm10 llvm12
reorgnization done
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 11:55:54 +0900 |
parents | 1d019706d866 |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
172:9fbae9c8bf63 | 173:0572611fdcc8 |
---|---|
71 | 71 |
72 } // namespace std | 72 } // namespace std |
73 | 73 |
74 */ | 74 */ |
75 | 75 |
76 #include <__config> | |
76 #include <__errc> | 77 #include <__errc> |
77 #include <type_traits> | 78 #include <type_traits> |
78 #include <limits> | 79 #include <limits> |
79 #include <stdint.h> | 80 #include <stdint.h> |
80 #include <string.h> | 81 #include <string.h> |
90 #include <__undef_macros> | 91 #include <__undef_macros> |
91 | 92 |
92 _LIBCPP_BEGIN_NAMESPACE_STD | 93 _LIBCPP_BEGIN_NAMESPACE_STD |
93 | 94 |
94 namespace __itoa { | 95 namespace __itoa { |
95 _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer); | 96 _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; |
96 _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer); | 97 _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; |
97 } | 98 } |
98 | 99 |
99 #ifndef _LIBCPP_CXX03_LANG | 100 #ifndef _LIBCPP_CXX03_LANG |
100 | 101 |
101 enum class _LIBCPP_ENUM_VIS chars_format | 102 enum class _LIBCPP_ENUM_VIS chars_format |
165 auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12; | 166 auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12; |
166 return __t - (__v < __pow10_64[__t]) + 1; | 167 return __t - (__v < __pow10_64[__t]) + 1; |
167 } | 168 } |
168 #endif | 169 #endif |
169 | 170 |
171 _LIBCPP_AVAILABILITY_TO_CHARS | |
170 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | 172 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
171 { | 173 { |
172 return __u64toa(__v, __p); | 174 return __u64toa(__v, __p); |
173 } | 175 } |
174 | 176 |
187 auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12; | 189 auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12; |
188 return __t - (__v < __pow10_32[__t]) + 1; | 190 return __t - (__v < __pow10_32[__t]) + 1; |
189 } | 191 } |
190 #endif | 192 #endif |
191 | 193 |
194 _LIBCPP_AVAILABILITY_TO_CHARS | |
192 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | 195 static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
193 { | 196 { |
194 return __u32toa(__v, __p); | 197 return __u32toa(__v, __p); |
195 } | 198 } |
196 | 199 |
290 { | 293 { |
291 return static_cast<typename make_unsigned<_Tp>::type>(__x); | 294 return static_cast<typename make_unsigned<_Tp>::type>(__x); |
292 } | 295 } |
293 | 296 |
294 template <typename _Tp> | 297 template <typename _Tp> |
298 _LIBCPP_AVAILABILITY_TO_CHARS | |
295 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 299 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
296 __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) | 300 __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) |
297 { | 301 { |
298 auto __x = __to_unsigned(__value); | 302 auto __x = __to_unsigned(__value); |
299 if (__value < 0 && __first != __last) | 303 if (__value < 0 && __first != __last) |
304 | 308 |
305 return __to_chars_itoa(__first, __last, __x, false_type()); | 309 return __to_chars_itoa(__first, __last, __x, false_type()); |
306 } | 310 } |
307 | 311 |
308 template <typename _Tp> | 312 template <typename _Tp> |
313 _LIBCPP_AVAILABILITY_TO_CHARS | |
309 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 314 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
310 __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) | 315 __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) |
311 { | 316 { |
312 using __tx = __itoa::__traits<_Tp>; | 317 using __tx = __itoa::__traits<_Tp>; |
313 auto __diff = __last - __first; | 318 auto __diff = __last - __first; |
335 } | 340 } |
336 #endif | 341 #endif |
337 } | 342 } |
338 | 343 |
339 template <typename _Tp> | 344 template <typename _Tp> |
345 _LIBCPP_AVAILABILITY_TO_CHARS | |
340 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 346 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
341 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | 347 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
342 true_type) | 348 true_type) |
343 { | 349 { |
344 auto __x = __to_unsigned(__value); | 350 auto __x = __to_unsigned(__value); |
350 | 356 |
351 return __to_chars_integral(__first, __last, __x, __base, false_type()); | 357 return __to_chars_integral(__first, __last, __x, __base, false_type()); |
352 } | 358 } |
353 | 359 |
354 template <typename _Tp> | 360 template <typename _Tp> |
361 _LIBCPP_AVAILABILITY_TO_CHARS | |
355 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 362 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
356 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, | 363 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
357 false_type) | 364 false_type) |
358 { | 365 { |
359 if (__base == 10) | 366 if (__base == 10) |
378 return {__first + __len, {}}; | 385 return {__first + __len, {}}; |
379 } | 386 } |
380 } | 387 } |
381 | 388 |
382 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> | 389 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
390 _LIBCPP_AVAILABILITY_TO_CHARS | |
383 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 391 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
384 to_chars(char* __first, char* __last, _Tp __value) | 392 to_chars(char* __first, char* __last, _Tp __value) |
385 { | 393 { |
386 return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>()); | 394 return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>()); |
387 } | 395 } |
388 | 396 |
389 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> | 397 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
398 _LIBCPP_AVAILABILITY_TO_CHARS | |
390 inline _LIBCPP_INLINE_VISIBILITY to_chars_result | 399 inline _LIBCPP_INLINE_VISIBILITY to_chars_result |
391 to_chars(char* __first, char* __last, _Tp __value, int __base) | 400 to_chars(char* __first, char* __last, _Tp __value, int __base) |
392 { | 401 { |
393 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); | 402 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); |
394 return __to_chars_integral(__first, __last, __value, __base, | 403 return __to_chars_integral(__first, __last, __value, __base, |