66#include < cstring>
77#include < iterator>
88
9- #if defined __has_include
10- #if __has_include(<version>)
11- #include < version>
12- #if defined(__cpp_lib_bit_cast)
13- #include < bit>
14- #endif
15- #endif
16- #endif
17-
189#include " float_common.h"
1910
2011namespace fast_float {
2112
2213// Next function can be micro-optimized, but compilers are entirely
2314// able to optimize it well.
24- CXX20_CONSTEXPR fastfloat_really_inline bool is_integer (char c) noexcept { return c >= ' 0' && c <= ' 9' ; }
15+ fastfloat_really_inline bool is_integer (char c) noexcept { return c >= ' 0' && c <= ' 9' ; }
2516
26- CXX20_CONSTEXPR fastfloat_really_inline uint64_t byteswap (uint64_t val) {
17+ fastfloat_really_inline uint64_t byteswap (uint64_t val) {
2718 return (val & 0xFF00000000000000 ) >> 56
2819 | (val & 0x00FF000000000000 ) >> 40
2920 | (val & 0x0000FF0000000000 ) >> 24
@@ -34,40 +25,26 @@ CXX20_CONSTEXPR fastfloat_really_inline uint64_t byteswap(uint64_t val) {
3425 | (val & 0x00000000000000FF ) << 56 ;
3526}
3627
37- CXX20_CONSTEXPR fastfloat_really_inline uint64_t read_u64 (const char *chars) {
28+ fastfloat_really_inline uint64_t read_u64 (const char *chars) {
3829 uint64_t val;
39- #if defined(__cpp_lib_bit_cast)
40- val = std::bit_cast<uint64_t >(reinterpret_cast <const char (&)[8 ]>(chars));
41- #else
4230 ::memcpy (&val, chars, sizeof (uint64_t ));
43- #endif
4431#if FASTFLOAT_IS_BIG_ENDIAN == 1
4532 // Need to read as-if the number was in little-endian order.
4633 val = byteswap (val);
4734#endif
4835 return val;
4936}
5037
51- CXX20_CONSTEXPR fastfloat_really_inline void write_u64 (uint8_t *chars, uint64_t val) {
38+ fastfloat_really_inline void write_u64 (uint8_t *chars, uint64_t val) {
5239#if FASTFLOAT_IS_BIG_ENDIAN == 1
5340 // Need to read as-if the number was in little-endian order.
5441 val = byteswap (val);
5542#endif
56- #if defined(__cpp_lib_bit_cast)
57- if (std::is_constant_evaluated ()) {
58- char (&dst)[8 ] = reinterpret_cast <char (&)[8 ]>(chars);
59- const char (&src)[8 ] = reinterpret_cast <const char (&)[8 ]>(val);
60- std::copy (std::begin (src), std::end (src), std::begin (dst));
61- } else {
62- ::memcpy (chars, &val, sizeof (uint64_t ));
63- }
64- #else
6543 ::memcpy (chars, &val, sizeof (uint64_t ));
66- #endif
6744}
6845
6946// credit @aqrit
70- CXX20_CONSTEXPR fastfloat_really_inline uint32_t parse_eight_digits_unrolled (uint64_t val) {
47+ fastfloat_really_inline uint32_t parse_eight_digits_unrolled (uint64_t val) {
7148 const uint64_t mask = 0x000000FF000000FF ;
7249 const uint64_t mul1 = 0x000F424000000064 ; // 100 + (1000000ULL << 32)
7350 const uint64_t mul2 = 0x0000271000000001 ; // 1 + (10000ULL << 32)
@@ -77,17 +54,17 @@ CXX20_CONSTEXPR fastfloat_really_inline uint32_t parse_eight_digits_unrolled(ui
7754 return uint32_t (val);
7855}
7956
80- CXX20_CONSTEXPR fastfloat_really_inline uint32_t parse_eight_digits_unrolled (const char *chars) noexcept {
57+ fastfloat_really_inline uint32_t parse_eight_digits_unrolled (const char *chars) noexcept {
8158 return parse_eight_digits_unrolled (read_u64 (chars));
8259}
8360
8461// credit @aqrit
85- CXX20_CONSTEXPR fastfloat_really_inline bool is_made_of_eight_digits_fast (uint64_t val) noexcept {
62+ fastfloat_really_inline bool is_made_of_eight_digits_fast (uint64_t val) noexcept {
8663 return !((((val + 0x4646464646464646 ) | (val - 0x3030303030303030 )) &
8764 0x8080808080808080 ));
8865}
8966
90- CXX20_CONSTEXPR fastfloat_really_inline bool is_made_of_eight_digits_fast (const char *chars) noexcept {
67+ fastfloat_really_inline bool is_made_of_eight_digits_fast (const char *chars) noexcept {
9168 return is_made_of_eight_digits_fast (read_u64 (chars));
9269}
9370
@@ -107,7 +84,7 @@ struct parsed_number_string {
10784
10885// Assuming that you use no more than 19 digits, this will
10986// parse an ASCII string.
110- CXX20_CONSTEXPR fastfloat_really_inline
87+ fastfloat_really_inline
11188parsed_number_string parse_number_string (const char *p, const char *pend, parse_options options) noexcept {
11289 const chars_format fmt = options.format ;
11390 const char decimal_point = options.decimal_point ;
0 commit comments