ycpp 0.1.3__cp312-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. ycpp/__init__.py +110 -0
  2. ycpp/_array.py +318 -0
  3. ycpp/_awareness.py +268 -0
  4. ycpp/_doc.py +718 -0
  5. ycpp/_event.py +188 -0
  6. ycpp/_id_map.py +620 -0
  7. ycpp/_map.py +267 -0
  8. ycpp/_provider.py +180 -0
  9. ycpp/_snapshot.py +28 -0
  10. ycpp/_sticky_index.py +59 -0
  11. ycpp/_stream.py +91 -0
  12. ycpp/_sync.py +192 -0
  13. ycpp/_text.py +239 -0
  14. ycpp/_transaction.py +287 -0
  15. ycpp/_typed.py +122 -0
  16. ycpp/_undo.py +201 -0
  17. ycpp/_update.py +18 -0
  18. ycpp/_xml.py +452 -0
  19. ycpp/_ycpp.lib +0 -0
  20. ycpp/_ycpp.pyd +0 -0
  21. ycpp-0.1.3.data/headers/fast_float/ascii_number.h +766 -0
  22. ycpp-0.1.3.data/headers/fast_float/bigint.h +638 -0
  23. ycpp-0.1.3.data/headers/fast_float/constexpr_feature_detect.h +53 -0
  24. ycpp-0.1.3.data/headers/fast_float/decimal_to_binary.h +212 -0
  25. ycpp-0.1.3.data/headers/fast_float/digit_comparison.h +455 -0
  26. ycpp-0.1.3.data/headers/fast_float/fast_float.h +91 -0
  27. ycpp-0.1.3.data/headers/fast_float/fast_table.h +708 -0
  28. ycpp-0.1.3.data/headers/fast_float/float_common.h +1432 -0
  29. ycpp-0.1.3.data/headers/fast_float/parse_number.h +488 -0
  30. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  31. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
  32. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  33. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  34. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  35. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  36. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  37. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  38. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  39. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  40. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  41. ycpp-0.1.3.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
  42. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
  43. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
  44. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  45. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  46. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  47. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
  48. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  49. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  50. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  51. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  52. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  53. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  54. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  55. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  56. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
  57. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  58. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
  59. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
  60. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  61. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  62. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  63. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
  64. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  65. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
  66. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
  67. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
  68. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
  69. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
  70. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
  71. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
  72. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  73. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  74. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
  75. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
  76. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
  77. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
  78. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
  79. ycpp-0.1.3.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
  80. ycpp-0.1.3.data/headers/xsimd/config/xsimd_config.hpp +620 -0
  81. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
  82. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  83. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  84. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  85. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  86. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
  87. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
  88. ycpp-0.1.3.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
  89. ycpp-0.1.3.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
  90. ycpp-0.1.3.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  91. ycpp-0.1.3.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  92. ycpp-0.1.3.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
  93. ycpp-0.1.3.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
  94. ycpp-0.1.3.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
  95. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
  96. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  97. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  98. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  99. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  100. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  101. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  102. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  103. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  104. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  105. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  106. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  107. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
  108. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  109. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
  110. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
  111. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  112. ycpp-0.1.3.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
  113. ycpp-0.1.3.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
  114. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  115. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  116. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  117. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
  118. ycpp-0.1.3.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  119. ycpp-0.1.3.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
  120. ycpp-0.1.3.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
  121. ycpp-0.1.3.data/headers/xsimd/types/xsimd_register.hpp +96 -0
  122. ycpp-0.1.3.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
  123. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
  124. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
  125. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  126. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  127. ycpp-0.1.3.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  128. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
  129. ycpp-0.1.3.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
  130. ycpp-0.1.3.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
  131. ycpp-0.1.3.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
  132. ycpp-0.1.3.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
  133. ycpp-0.1.3.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
  134. ycpp-0.1.3.data/headers/xsimd/utils/bits.hpp +122 -0
  135. ycpp-0.1.3.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
  136. ycpp-0.1.3.data/headers/xsimd/xsimd.hpp +43 -0
  137. ycpp-0.1.3.dist-info/DELVEWHEEL +2 -0
  138. ycpp-0.1.3.dist-info/METADATA +15 -0
  139. ycpp-0.1.3.dist-info/RECORD +142 -0
  140. ycpp-0.1.3.dist-info/WHEEL +4 -0
  141. ycpp.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  142. ycpp.libs/msvcp140_1-226498d4bfcb4f07974757b596ebec45.dll +0 -0
@@ -0,0 +1,1432 @@
1
+ #ifndef FASTFLOAT_FLOAT_COMMON_H
2
+ #define FASTFLOAT_FLOAT_COMMON_H
3
+
4
+ #include <cfloat>
5
+ #include <cstddef>
6
+ #include <cstdint>
7
+ #include <cassert>
8
+ #include <cstring>
9
+ #include <limits>
10
+ #include <type_traits>
11
+ #include <system_error>
12
+ #ifdef __has_include
13
+ #if __has_include(<stdfloat>) && (__cplusplus > 202002L || (defined(_MSVC_LANG) && (_MSVC_LANG > 202002L)))
14
+ #include <stdfloat>
15
+ #endif
16
+ #endif
17
+ #include "constexpr_feature_detect.h"
18
+
19
+ #define FASTFLOAT_VERSION_MAJOR 8
20
+ #define FASTFLOAT_VERSION_MINOR 2
21
+ #define FASTFLOAT_VERSION_PATCH 4
22
+
23
+ #define FASTFLOAT_STRINGIZE_IMPL(x) #x
24
+ #define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
25
+
26
+ #define FASTFLOAT_VERSION_STR \
27
+ FASTFLOAT_STRINGIZE(FASTFLOAT_VERSION_MAJOR) \
28
+ "." FASTFLOAT_STRINGIZE(FASTFLOAT_VERSION_MINOR) "." FASTFLOAT_STRINGIZE( \
29
+ FASTFLOAT_VERSION_PATCH)
30
+
31
+ #define FASTFLOAT_VERSION \
32
+ (FASTFLOAT_VERSION_MAJOR * 10000 + FASTFLOAT_VERSION_MINOR * 100 + \
33
+ FASTFLOAT_VERSION_PATCH)
34
+
35
+ namespace fast_float {
36
+
37
+ enum class chars_format : uint64_t;
38
+
39
+ namespace detail {
40
+ constexpr chars_format basic_json_fmt = chars_format(1 << 5);
41
+ constexpr chars_format basic_fortran_fmt = chars_format(1 << 6);
42
+ } // namespace detail
43
+
44
+ enum class chars_format : uint64_t {
45
+ scientific = 1 << 0,
46
+ fixed = 1 << 2,
47
+ hex = 1 << 3,
48
+ no_infnan = 1 << 4,
49
+ // RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6
50
+ json = uint64_t(detail::basic_json_fmt) | fixed | scientific | no_infnan,
51
+ // Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed.
52
+ json_or_infnan = uint64_t(detail::basic_json_fmt) | fixed | scientific,
53
+ fortran = uint64_t(detail::basic_fortran_fmt) | fixed | scientific,
54
+ general = fixed | scientific,
55
+ allow_leading_plus = 1 << 7,
56
+ skip_white_space = 1 << 8,
57
+ };
58
+
59
+ template <typename UC> struct from_chars_result_t {
60
+ UC const *ptr;
61
+ std::errc ec;
62
+
63
+ // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2497r0.html
64
+ constexpr explicit operator bool() const noexcept {
65
+ return ec == std::errc();
66
+ }
67
+ };
68
+
69
+ using from_chars_result = from_chars_result_t<char>;
70
+
71
+ template <typename UC> struct parse_options_t {
72
+ constexpr explicit parse_options_t(chars_format fmt = chars_format::general,
73
+ UC dot = UC('.'), int b = 10)
74
+ : format(fmt), decimal_point(dot), base(b) {}
75
+
76
+ /** Which number formats are accepted */
77
+ chars_format format;
78
+ /** The character used as decimal point */
79
+ UC decimal_point;
80
+ /** The base used for integers */
81
+ int base;
82
+ };
83
+
84
+ using parse_options = parse_options_t<char>;
85
+
86
+ } // namespace fast_float
87
+
88
+ #if FASTFLOAT_HAS_BIT_CAST
89
+ #include <bit>
90
+ #endif
91
+
92
+ #if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
93
+ defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) || \
94
+ defined(__MINGW64__) || defined(__s390x__) || \
95
+ (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \
96
+ defined(__PPC64LE__)) || \
97
+ defined(__loongarch64) || (defined(__riscv) && __riscv_xlen == 64))
98
+ #define FASTFLOAT_64BIT 1
99
+ #elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
100
+ defined(__arm__) || defined(_M_ARM) || defined(__ppc__) || \
101
+ defined(__MINGW32__) || defined(__EMSCRIPTEN__) || \
102
+ (defined(__riscv) && __riscv_xlen == 32))
103
+ #define FASTFLOAT_32BIT 1
104
+ #else
105
+ // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow.
106
+ // We can never tell the register width, but the SIZE_MAX is a good
107
+ // approximation. UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max
108
+ // portability.
109
+ #if SIZE_MAX == 0xffff
110
+ #error Unknown platform (16-bit, unsupported)
111
+ #elif SIZE_MAX == 0xffffffff
112
+ #define FASTFLOAT_32BIT 1
113
+ #elif SIZE_MAX == 0xffffffffffffffff
114
+ #define FASTFLOAT_64BIT 1
115
+ #else
116
+ #error Unknown platform (not 32-bit, not 64-bit?)
117
+ #endif
118
+ #endif
119
+
120
+ #if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) || \
121
+ (defined(_M_ARM64) && !defined(__MINGW32__))
122
+ #include <intrin.h>
123
+ #endif
124
+
125
+ #if defined(_MSC_VER) && !defined(__clang__)
126
+ #define FASTFLOAT_VISUAL_STUDIO 1
127
+ #endif
128
+
129
+ #if defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__
130
+ #define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
131
+ #elif defined _WIN32
132
+ #define FASTFLOAT_IS_BIG_ENDIAN 0
133
+ #else
134
+ #if defined(__APPLE__) || defined(__FreeBSD__)
135
+ #include <machine/endian.h>
136
+ #elif defined(sun) || defined(__sun)
137
+ #include <sys/byteorder.h>
138
+ #elif defined(__MVS__)
139
+ #include <sys/endian.h>
140
+ #else
141
+ #ifdef __has_include
142
+ #if __has_include(<endian.h>)
143
+ #include <endian.h>
144
+ #endif //__has_include(<endian.h>)
145
+ #endif //__has_include
146
+ #endif
147
+ #
148
+ #ifndef __BYTE_ORDER__
149
+ // safe choice
150
+ #define FASTFLOAT_IS_BIG_ENDIAN 0
151
+ #endif
152
+ #
153
+ #ifndef __ORDER_LITTLE_ENDIAN__
154
+ // safe choice
155
+ #define FASTFLOAT_IS_BIG_ENDIAN 0
156
+ #endif
157
+ #
158
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
159
+ #define FASTFLOAT_IS_BIG_ENDIAN 0
160
+ #else
161
+ #define FASTFLOAT_IS_BIG_ENDIAN 1
162
+ #endif
163
+ #endif
164
+
165
+ #if defined(__SSE2__) || (defined(FASTFLOAT_VISUAL_STUDIO) && \
166
+ (defined(_M_AMD64) || defined(_M_X64) || \
167
+ (defined(_M_IX86_FP) && _M_IX86_FP == 2)))
168
+ #define FASTFLOAT_SSE2 1
169
+ #endif
170
+
171
+ #if defined(__aarch64__) || defined(_M_ARM64)
172
+ #define FASTFLOAT_NEON 1
173
+ #endif
174
+
175
+ #if defined(FASTFLOAT_SSE2) || defined(FASTFLOAT_NEON)
176
+ #define FASTFLOAT_HAS_SIMD 1
177
+ #endif
178
+
179
+ #if defined(__GNUC__)
180
+ // disable -Wcast-align=strict (GCC only)
181
+ #define FASTFLOAT_SIMD_DISABLE_WARNINGS \
182
+ _Pragma("GCC diagnostic push") \
183
+ _Pragma("GCC diagnostic ignored \"-Wcast-align\"")
184
+ #else
185
+ #define FASTFLOAT_SIMD_DISABLE_WARNINGS
186
+ #endif
187
+
188
+ #if defined(__GNUC__)
189
+ #define FASTFLOAT_SIMD_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
190
+ #else
191
+ #define FASTFLOAT_SIMD_RESTORE_WARNINGS
192
+ #endif
193
+
194
+ #ifdef FASTFLOAT_VISUAL_STUDIO
195
+ #define fastfloat_really_inline __forceinline
196
+ #else
197
+ #define fastfloat_really_inline inline __attribute__((always_inline))
198
+ #endif
199
+
200
+ #ifndef FASTFLOAT_ASSERT
201
+ #define FASTFLOAT_ASSERT(x) \
202
+ { ((void)(x)); }
203
+ #endif
204
+
205
+ #ifndef FASTFLOAT_DEBUG_ASSERT
206
+ #define FASTFLOAT_DEBUG_ASSERT(x) \
207
+ { ((void)(x)); }
208
+ #endif
209
+
210
+ // rust style `try!()` macro, or `?` operator
211
+ #define FASTFLOAT_TRY(x) \
212
+ { \
213
+ if (!(x)) \
214
+ return false; \
215
+ }
216
+
217
+ #define FASTFLOAT_ENABLE_IF(...) \
218
+ typename std::enable_if<(__VA_ARGS__), int>::type
219
+
220
+ namespace fast_float {
221
+
222
+ fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() {
223
+ #if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED
224
+ return std::is_constant_evaluated();
225
+ #else
226
+ return false;
227
+ #endif
228
+ }
229
+
230
+ template <typename T>
231
+ struct is_supported_float_type
232
+ : std::integral_constant<
233
+ bool, std::is_same<T, double>::value || std::is_same<T, float>::value
234
+ #ifdef __STDCPP_FLOAT64_T__
235
+ || std::is_same<T, std::float64_t>::value
236
+ #endif
237
+ #ifdef __STDCPP_FLOAT32_T__
238
+ || std::is_same<T, std::float32_t>::value
239
+ #endif
240
+ #ifdef __STDCPP_FLOAT16_T__
241
+ || std::is_same<T, std::float16_t>::value
242
+ #endif
243
+ #ifdef __STDCPP_BFLOAT16_T__
244
+ || std::is_same<T, std::bfloat16_t>::value
245
+ #endif
246
+ > {
247
+ };
248
+
249
+ template <typename T>
250
+ using equiv_uint_t = typename std::conditional<
251
+ sizeof(T) == 1, uint8_t,
252
+ typename std::conditional<
253
+ sizeof(T) == 2, uint16_t,
254
+ typename std::conditional<sizeof(T) == 4, uint32_t,
255
+ uint64_t>::type>::type>::type;
256
+
257
+ template <typename T> struct is_supported_integer_type : std::is_integral<T> {};
258
+
259
+ template <typename UC>
260
+ struct is_supported_char_type
261
+ : std::integral_constant<bool, std::is_same<UC, char>::value ||
262
+ std::is_same<UC, wchar_t>::value ||
263
+ std::is_same<UC, char16_t>::value ||
264
+ std::is_same<UC, char32_t>::value
265
+ #ifdef __cpp_char8_t
266
+ || std::is_same<UC, char8_t>::value
267
+ #endif
268
+ > {
269
+ };
270
+
271
+ template <typename UC>
272
+ inline FASTFLOAT_CONSTEXPR14 bool
273
+ fastfloat_strncasecmp3(UC const *actual_mixedcase,
274
+ UC const *expected_lowercase) {
275
+ uint64_t mask{0};
276
+ FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1) { mask = 0x2020202020202020; }
277
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 2) {
278
+ mask = 0x0020002000200020;
279
+ }
280
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
281
+ mask = 0x0000002000000020;
282
+ }
283
+ else {
284
+ return false;
285
+ }
286
+
287
+ uint64_t val1{0}, val2{0};
288
+ if (cpp20_and_in_constexpr()) {
289
+ for (size_t i = 0; i < 3; i++) {
290
+ if ((actual_mixedcase[i] | 32) != expected_lowercase[i]) {
291
+ return false;
292
+ }
293
+ }
294
+ return true;
295
+ } else {
296
+ FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1 || sizeof(UC) == 2) {
297
+ ::memcpy(&val1, actual_mixedcase, 3 * sizeof(UC));
298
+ ::memcpy(&val2, expected_lowercase, 3 * sizeof(UC));
299
+ val1 |= mask;
300
+ val2 |= mask;
301
+ return val1 == val2;
302
+ }
303
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
304
+ ::memcpy(&val1, actual_mixedcase, 2 * sizeof(UC));
305
+ ::memcpy(&val2, expected_lowercase, 2 * sizeof(UC));
306
+ val1 |= mask;
307
+ if (val1 != val2) {
308
+ return false;
309
+ }
310
+ return (actual_mixedcase[2] | 32) == (expected_lowercase[2]);
311
+ }
312
+ else {
313
+ return false;
314
+ }
315
+ }
316
+ }
317
+
318
+ template <typename UC>
319
+ inline FASTFLOAT_CONSTEXPR14 bool
320
+ fastfloat_strncasecmp5(UC const *actual_mixedcase,
321
+ UC const *expected_lowercase) {
322
+ uint64_t mask{0};
323
+ uint64_t val1{0}, val2{0};
324
+ if (cpp20_and_in_constexpr()) {
325
+ for (size_t i = 0; i < 5; i++) {
326
+ if ((actual_mixedcase[i] | 32) != expected_lowercase[i]) {
327
+ return false;
328
+ }
329
+ }
330
+ return true;
331
+ } else {
332
+ FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1) {
333
+ mask = 0x2020202020202020;
334
+ ::memcpy(&val1, actual_mixedcase, 5 * sizeof(UC));
335
+ ::memcpy(&val2, expected_lowercase, 5 * sizeof(UC));
336
+ val1 |= mask;
337
+ val2 |= mask;
338
+ return val1 == val2;
339
+ }
340
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 2) {
341
+ mask = 0x0020002000200020;
342
+ ::memcpy(&val1, actual_mixedcase, 4 * sizeof(UC));
343
+ ::memcpy(&val2, expected_lowercase, 4 * sizeof(UC));
344
+ val1 |= mask;
345
+ if (val1 != val2) {
346
+ return false;
347
+ }
348
+ return (actual_mixedcase[4] | 32) == (expected_lowercase[4]);
349
+ }
350
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
351
+ mask = 0x0000002000000020;
352
+ ::memcpy(&val1, actual_mixedcase, 2 * sizeof(UC));
353
+ ::memcpy(&val2, expected_lowercase, 2 * sizeof(UC));
354
+ val1 |= mask;
355
+ if (val1 != val2) {
356
+ return false;
357
+ }
358
+ ::memcpy(&val1, actual_mixedcase + 2, 2 * sizeof(UC));
359
+ ::memcpy(&val2, expected_lowercase + 2, 2 * sizeof(UC));
360
+ val1 |= mask;
361
+ if (val1 != val2) {
362
+ return false;
363
+ }
364
+ return (actual_mixedcase[4] | 32) == (expected_lowercase[4]);
365
+ }
366
+ else {
367
+ return false;
368
+ }
369
+ }
370
+ }
371
+
372
+ // Compares two ASCII strings in a case insensitive manner.
373
+ template <typename UC>
374
+ inline FASTFLOAT_CONSTEXPR14 bool
375
+ fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
376
+ size_t length) {
377
+ uint64_t mask{0};
378
+ FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1) { mask = 0x2020202020202020; }
379
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 2) {
380
+ mask = 0x0020002000200020;
381
+ }
382
+ else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
383
+ mask = 0x0000002000000020;
384
+ }
385
+ else {
386
+ return false;
387
+ }
388
+
389
+ if (cpp20_and_in_constexpr()) {
390
+ for (size_t i = 0; i < length; i++) {
391
+ if ((actual_mixedcase[i] | 32) != expected_lowercase[i]) {
392
+ return false;
393
+ }
394
+ }
395
+ return true;
396
+ } else {
397
+ uint64_t val1{0}, val2{0};
398
+ size_t sz{8 / (sizeof(UC))};
399
+ for (size_t i = 0; i < length; i += sz) {
400
+ val1 = val2 = 0;
401
+ sz = std::min(sz, length - i);
402
+ ::memcpy(&val1, actual_mixedcase + i, sz * sizeof(UC));
403
+ ::memcpy(&val2, expected_lowercase + i, sz * sizeof(UC));
404
+ val1 |= mask;
405
+ val2 |= mask;
406
+ if (val1 != val2) {
407
+ return false;
408
+ }
409
+ }
410
+ return true;
411
+ }
412
+ }
413
+
414
+ #ifndef FLT_EVAL_METHOD
415
+ #error "FLT_EVAL_METHOD should be defined, please include cfloat."
416
+ #endif
417
+
418
+ // a pointer and a length to a contiguous block of memory
419
+ template <typename T> struct span {
420
+ T const *ptr;
421
+ size_t length;
422
+
423
+ constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
424
+
425
+ constexpr span() : ptr(nullptr), length(0) {}
426
+
427
+ constexpr size_t len() const noexcept { return length; }
428
+
429
+ FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept {
430
+ FASTFLOAT_DEBUG_ASSERT(index < length);
431
+ return ptr[index];
432
+ }
433
+ };
434
+
435
+ struct value128 {
436
+ uint64_t low;
437
+ uint64_t high;
438
+
439
+ constexpr value128(uint64_t _low, uint64_t _high) : low(_low), high(_high) {}
440
+
441
+ constexpr value128() : low(0), high(0) {}
442
+ };
443
+
444
+ /* Helper C++14 constexpr generic implementation of leading_zeroes */
445
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int
446
+ leading_zeroes_generic(uint64_t input_num, int last_bit = 0) {
447
+ if (input_num & uint64_t(0xffffffff00000000)) {
448
+ input_num >>= 32;
449
+ last_bit |= 32;
450
+ }
451
+ if (input_num & uint64_t(0xffff0000)) {
452
+ input_num >>= 16;
453
+ last_bit |= 16;
454
+ }
455
+ if (input_num & uint64_t(0xff00)) {
456
+ input_num >>= 8;
457
+ last_bit |= 8;
458
+ }
459
+ if (input_num & uint64_t(0xf0)) {
460
+ input_num >>= 4;
461
+ last_bit |= 4;
462
+ }
463
+ if (input_num & uint64_t(0xc)) {
464
+ input_num >>= 2;
465
+ last_bit |= 2;
466
+ }
467
+ if (input_num & uint64_t(0x2)) { /* input_num >>= 1; */
468
+ last_bit |= 1;
469
+ }
470
+ return 63 - last_bit;
471
+ }
472
+
473
+ /* result might be undefined when input_num is zero */
474
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 int
475
+ leading_zeroes(uint64_t input_num) {
476
+ assert(input_num > 0);
477
+ if (cpp20_and_in_constexpr()) {
478
+ return leading_zeroes_generic(input_num);
479
+ }
480
+ #ifdef FASTFLOAT_VISUAL_STUDIO
481
+ #if defined(_M_X64) || defined(_M_ARM64)
482
+ unsigned long leading_zero = 0;
483
+ // Search the mask data from most significant bit (MSB)
484
+ // to least significant bit (LSB) for a set bit (1).
485
+ _BitScanReverse64(&leading_zero, input_num);
486
+ return (int)(63 - leading_zero);
487
+ #else
488
+ return leading_zeroes_generic(input_num);
489
+ #endif
490
+ #else
491
+ return __builtin_clzll(input_num);
492
+ #endif
493
+ }
494
+
495
+ /* Helper C++14 constexpr generic implementation of countr_zero for 32-bit */
496
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int
497
+ countr_zero_generic_32(uint32_t input_num) {
498
+ if (input_num == 0) {
499
+ return 32;
500
+ }
501
+ int last_bit = 0;
502
+ if (!(input_num & 0x0000FFFF)) {
503
+ input_num >>= 16;
504
+ last_bit |= 16;
505
+ }
506
+ if (!(input_num & 0x00FF)) {
507
+ input_num >>= 8;
508
+ last_bit |= 8;
509
+ }
510
+ if (!(input_num & 0x0F)) {
511
+ input_num >>= 4;
512
+ last_bit |= 4;
513
+ }
514
+ if (!(input_num & 0x3)) {
515
+ input_num >>= 2;
516
+ last_bit |= 2;
517
+ }
518
+ if (!(input_num & 0x1)) {
519
+ last_bit |= 1;
520
+ }
521
+ return last_bit;
522
+ }
523
+
524
+ /* count trailing zeroes for 32-bit integers */
525
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 int
526
+ countr_zero_32(uint32_t input_num) {
527
+ if (cpp20_and_in_constexpr()) {
528
+ return countr_zero_generic_32(input_num);
529
+ }
530
+ #ifdef FASTFLOAT_VISUAL_STUDIO
531
+ unsigned long trailing_zero = 0;
532
+ if (_BitScanForward(&trailing_zero, input_num)) {
533
+ return (int)trailing_zero;
534
+ }
535
+ return 32;
536
+ #else
537
+ return input_num == 0 ? 32 : __builtin_ctz(input_num);
538
+ #endif
539
+ }
540
+
541
+ // slow emulation routine for 32-bit
542
+ fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, uint32_t y) {
543
+ return x * (uint64_t)y;
544
+ }
545
+
546
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t
547
+ umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) {
548
+ uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd);
549
+ uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd);
550
+ uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32));
551
+ uint64_t adbc_carry = (uint64_t)(adbc < ad);
552
+ uint64_t lo = bd + (adbc << 32);
553
+ *hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) +
554
+ (adbc_carry << 32) + (uint64_t)(lo < bd);
555
+ return lo;
556
+ }
557
+
558
+ #ifdef FASTFLOAT_32BIT
559
+
560
+ // slow emulation routine for 32-bit
561
+ #if !defined(__MINGW64__)
562
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t _umul128(uint64_t ab,
563
+ uint64_t cd,
564
+ uint64_t *hi) {
565
+ return umul128_generic(ab, cd, hi);
566
+ }
567
+ #endif // !__MINGW64__
568
+
569
+ #endif // FASTFLOAT_32BIT
570
+
571
+ // compute 64-bit a*b
572
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
573
+ full_multiplication(uint64_t a, uint64_t b) {
574
+ if (cpp20_and_in_constexpr()) {
575
+ value128 answer;
576
+ answer.low = umul128_generic(a, b, &answer.high);
577
+ return answer;
578
+ }
579
+ value128 answer;
580
+ #if defined(_M_ARM64) && !defined(__MINGW32__)
581
+ // ARM64 has native support for 64-bit multiplications, no need to emulate
582
+ // But MinGW on ARM64 doesn't have native support for 64-bit multiplications
583
+ answer.high = __umulh(a, b);
584
+ answer.low = a * b;
585
+ #elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__) && \
586
+ !defined(_M_ARM64) && !defined(__GNUC__))
587
+ answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64
588
+ #elif defined(FASTFLOAT_64BIT) && defined(__SIZEOF_INT128__)
589
+ __uint128_t r = ((__uint128_t)a) * b;
590
+ answer.low = uint64_t(r);
591
+ answer.high = uint64_t(r >> 64);
592
+ #else
593
+ answer.low = umul128_generic(a, b, &answer.high);
594
+ #endif
595
+ return answer;
596
+ }
597
+
598
+ struct adjusted_mantissa {
599
+ uint64_t mantissa{0};
600
+ int32_t power2{0}; // a negative value indicates an invalid result
601
+ adjusted_mantissa() = default;
602
+
603
+ constexpr bool operator==(adjusted_mantissa const &o) const {
604
+ return mantissa == o.mantissa && power2 == o.power2;
605
+ }
606
+
607
+ constexpr bool operator!=(adjusted_mantissa const &o) const {
608
+ return mantissa != o.mantissa || power2 != o.power2;
609
+ }
610
+ };
611
+
612
+ // Bias so we can get the real exponent with an invalid adjusted_mantissa.
613
+ constexpr static int32_t invalid_am_bias = -0x8000;
614
+
615
+ // used for binary_format_lookup_tables<T>::max_mantissa
616
+ constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5;
617
+
618
+ template <typename T, typename U = void> struct binary_format_lookup_tables;
619
+
620
+ template <typename T> struct binary_format : binary_format_lookup_tables<T> {
621
+ using equiv_uint = equiv_uint_t<T>;
622
+
623
+ static constexpr int mantissa_explicit_bits();
624
+ static constexpr int minimum_exponent();
625
+ static constexpr int infinite_power();
626
+ static constexpr int sign_index();
627
+ static constexpr int
628
+ min_exponent_fast_path(); // used when fegetround() == FE_TONEAREST
629
+ static constexpr int max_exponent_fast_path();
630
+ static constexpr int max_exponent_round_to_even();
631
+ static constexpr int min_exponent_round_to_even();
632
+ static constexpr uint64_t max_mantissa_fast_path(int64_t power);
633
+ static constexpr uint64_t
634
+ max_mantissa_fast_path(); // used when fegetround() == FE_TONEAREST
635
+ static constexpr int largest_power_of_ten();
636
+ static constexpr int smallest_power_of_ten();
637
+ static constexpr T exact_power_of_ten(int64_t power);
638
+ static constexpr size_t max_digits();
639
+ static constexpr equiv_uint exponent_mask();
640
+ static constexpr equiv_uint mantissa_mask();
641
+ static constexpr equiv_uint hidden_bit_mask();
642
+ };
643
+
644
+ template <typename U> struct binary_format_lookup_tables<double, U> {
645
+ static constexpr double powers_of_ten[] = {
646
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
647
+ 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
648
+
649
+ // Largest integer value v so that (5**index * v) <= 1<<53.
650
+ // 0x20000000000000 == 1 << 53
651
+ static constexpr uint64_t max_mantissa[] = {
652
+ 0x20000000000000,
653
+ 0x20000000000000 / 5,
654
+ 0x20000000000000 / (5 * 5),
655
+ 0x20000000000000 / (5 * 5 * 5),
656
+ 0x20000000000000 / (5 * 5 * 5 * 5),
657
+ 0x20000000000000 / (constant_55555),
658
+ 0x20000000000000 / (constant_55555 * 5),
659
+ 0x20000000000000 / (constant_55555 * 5 * 5),
660
+ 0x20000000000000 / (constant_55555 * 5 * 5 * 5),
661
+ 0x20000000000000 / (constant_55555 * 5 * 5 * 5 * 5),
662
+ 0x20000000000000 / (constant_55555 * constant_55555),
663
+ 0x20000000000000 / (constant_55555 * constant_55555 * 5),
664
+ 0x20000000000000 / (constant_55555 * constant_55555 * 5 * 5),
665
+ 0x20000000000000 / (constant_55555 * constant_55555 * 5 * 5 * 5),
666
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555),
667
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5),
668
+ 0x20000000000000 /
669
+ (constant_55555 * constant_55555 * constant_55555 * 5 * 5),
670
+ 0x20000000000000 /
671
+ (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5),
672
+ 0x20000000000000 /
673
+ (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5 * 5),
674
+ 0x20000000000000 /
675
+ (constant_55555 * constant_55555 * constant_55555 * constant_55555),
676
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 *
677
+ constant_55555 * 5),
678
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 *
679
+ constant_55555 * 5 * 5),
680
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 *
681
+ constant_55555 * 5 * 5 * 5),
682
+ 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 *
683
+ constant_55555 * 5 * 5 * 5 * 5)};
684
+ };
685
+
686
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
687
+
688
+ template <typename U>
689
+ constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[];
690
+
691
+ template <typename U>
692
+ constexpr uint64_t binary_format_lookup_tables<double, U>::max_mantissa[];
693
+
694
+ #endif
695
+
696
+ template <typename U> struct binary_format_lookup_tables<float, U> {
697
+ static constexpr float powers_of_ten[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f,
698
+ 1e6f, 1e7f, 1e8f, 1e9f, 1e10f};
699
+
700
+ // Largest integer value v so that (5**index * v) <= 1<<24.
701
+ // 0x1000000 == 1<<24
702
+ static constexpr uint64_t max_mantissa[] = {
703
+ 0x1000000,
704
+ 0x1000000 / 5,
705
+ 0x1000000 / (5 * 5),
706
+ 0x1000000 / (5 * 5 * 5),
707
+ 0x1000000 / (5 * 5 * 5 * 5),
708
+ 0x1000000 / (constant_55555),
709
+ 0x1000000 / (constant_55555 * 5),
710
+ 0x1000000 / (constant_55555 * 5 * 5),
711
+ 0x1000000 / (constant_55555 * 5 * 5 * 5),
712
+ 0x1000000 / (constant_55555 * 5 * 5 * 5 * 5),
713
+ 0x1000000 / (constant_55555 * constant_55555),
714
+ 0x1000000 / (constant_55555 * constant_55555 * 5)};
715
+ };
716
+
717
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
718
+
719
+ template <typename U>
720
+ constexpr float binary_format_lookup_tables<float, U>::powers_of_ten[];
721
+
722
+ template <typename U>
723
+ constexpr uint64_t binary_format_lookup_tables<float, U>::max_mantissa[];
724
+
725
+ #endif
726
+
727
+ template <>
728
+ inline constexpr int binary_format<double>::min_exponent_fast_path() {
729
+ #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
730
+ return 0;
731
+ #else
732
+ return -22;
733
+ #endif
734
+ }
735
+
736
+ template <>
737
+ inline constexpr int binary_format<float>::min_exponent_fast_path() {
738
+ #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
739
+ return 0;
740
+ #else
741
+ return -10;
742
+ #endif
743
+ }
744
+
745
+ template <>
746
+ inline constexpr int binary_format<double>::mantissa_explicit_bits() {
747
+ return 52;
748
+ }
749
+
750
+ template <>
751
+ inline constexpr int binary_format<float>::mantissa_explicit_bits() {
752
+ return 23;
753
+ }
754
+
755
+ template <>
756
+ inline constexpr int binary_format<double>::max_exponent_round_to_even() {
757
+ return 23;
758
+ }
759
+
760
+ template <>
761
+ inline constexpr int binary_format<float>::max_exponent_round_to_even() {
762
+ return 10;
763
+ }
764
+
765
+ template <>
766
+ inline constexpr int binary_format<double>::min_exponent_round_to_even() {
767
+ return -4;
768
+ }
769
+
770
+ template <>
771
+ inline constexpr int binary_format<float>::min_exponent_round_to_even() {
772
+ return -17;
773
+ }
774
+
775
+ template <> inline constexpr int binary_format<double>::minimum_exponent() {
776
+ return -1023;
777
+ }
778
+
779
+ template <> inline constexpr int binary_format<float>::minimum_exponent() {
780
+ return -127;
781
+ }
782
+
783
+ template <> inline constexpr int binary_format<double>::infinite_power() {
784
+ return 0x7FF;
785
+ }
786
+
787
+ template <> inline constexpr int binary_format<float>::infinite_power() {
788
+ return 0xFF;
789
+ }
790
+
791
+ template <> inline constexpr int binary_format<double>::sign_index() {
792
+ return 63;
793
+ }
794
+
795
+ template <> inline constexpr int binary_format<float>::sign_index() {
796
+ return 31;
797
+ }
798
+
799
+ template <>
800
+ inline constexpr int binary_format<double>::max_exponent_fast_path() {
801
+ return 22;
802
+ }
803
+
804
+ template <>
805
+ inline constexpr int binary_format<float>::max_exponent_fast_path() {
806
+ return 10;
807
+ }
808
+
809
+ template <>
810
+ inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
811
+ return uint64_t(2) << mantissa_explicit_bits();
812
+ }
813
+
814
+ template <>
815
+ inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() {
816
+ return uint64_t(2) << mantissa_explicit_bits();
817
+ }
818
+
819
+ // credit: Jakub Jelínek
820
+ #ifdef __STDCPP_FLOAT16_T__
821
+ template <typename U> struct binary_format_lookup_tables<std::float16_t, U> {
822
+ static constexpr std::float16_t powers_of_ten[] = {1e0f16, 1e1f16, 1e2f16,
823
+ 1e3f16, 1e4f16};
824
+
825
+ // Largest integer value v so that (5**index * v) <= 1<<11.
826
+ // 0x800 == 1<<11
827
+ static constexpr uint64_t max_mantissa[] = {0x800,
828
+ 0x800 / 5,
829
+ 0x800 / (5 * 5),
830
+ 0x800 / (5 * 5 * 5),
831
+ 0x800 / (5 * 5 * 5 * 5),
832
+ 0x800 / (constant_55555)};
833
+ };
834
+
835
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
836
+
837
+ template <typename U>
838
+ constexpr std::float16_t
839
+ binary_format_lookup_tables<std::float16_t, U>::powers_of_ten[];
840
+
841
+ template <typename U>
842
+ constexpr uint64_t
843
+ binary_format_lookup_tables<std::float16_t, U>::max_mantissa[];
844
+
845
+ #endif
846
+
847
+ template <>
848
+ inline constexpr std::float16_t
849
+ binary_format<std::float16_t>::exact_power_of_ten(int64_t power) {
850
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
851
+ return (void)powers_of_ten[0], powers_of_ten[power];
852
+ }
853
+
854
+ template <>
855
+ inline constexpr binary_format<std::float16_t>::equiv_uint
856
+ binary_format<std::float16_t>::exponent_mask() {
857
+ return 0x7C00;
858
+ }
859
+
860
+ template <>
861
+ inline constexpr binary_format<std::float16_t>::equiv_uint
862
+ binary_format<std::float16_t>::mantissa_mask() {
863
+ return 0x03FF;
864
+ }
865
+
866
+ template <>
867
+ inline constexpr binary_format<std::float16_t>::equiv_uint
868
+ binary_format<std::float16_t>::hidden_bit_mask() {
869
+ return 0x0400;
870
+ }
871
+
872
+ template <>
873
+ inline constexpr int binary_format<std::float16_t>::max_exponent_fast_path() {
874
+ return 4;
875
+ }
876
+
877
+ template <>
878
+ inline constexpr int binary_format<std::float16_t>::mantissa_explicit_bits() {
879
+ return 10;
880
+ }
881
+
882
+ template <>
883
+ inline constexpr uint64_t
884
+ binary_format<std::float16_t>::max_mantissa_fast_path() {
885
+ return uint64_t(2) << mantissa_explicit_bits();
886
+ }
887
+
888
+ template <>
889
+ inline constexpr uint64_t
890
+ binary_format<std::float16_t>::max_mantissa_fast_path(int64_t power) {
891
+ // caller is responsible to ensure that
892
+ // power >= 0 && power <= 4
893
+ //
894
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
895
+ return (void)max_mantissa[0], max_mantissa[power];
896
+ }
897
+
898
+ template <>
899
+ inline constexpr int binary_format<std::float16_t>::min_exponent_fast_path() {
900
+ return 0;
901
+ }
902
+
903
+ template <>
904
+ inline constexpr int
905
+ binary_format<std::float16_t>::max_exponent_round_to_even() {
906
+ return 5;
907
+ }
908
+
909
+ template <>
910
+ inline constexpr int
911
+ binary_format<std::float16_t>::min_exponent_round_to_even() {
912
+ return -22;
913
+ }
914
+
915
+ template <>
916
+ inline constexpr int binary_format<std::float16_t>::minimum_exponent() {
917
+ return -15;
918
+ }
919
+
920
+ template <>
921
+ inline constexpr int binary_format<std::float16_t>::infinite_power() {
922
+ return 0x1F;
923
+ }
924
+
925
+ template <> inline constexpr int binary_format<std::float16_t>::sign_index() {
926
+ return 15;
927
+ }
928
+
929
+ template <>
930
+ inline constexpr int binary_format<std::float16_t>::largest_power_of_ten() {
931
+ return 4;
932
+ }
933
+
934
+ template <>
935
+ inline constexpr int binary_format<std::float16_t>::smallest_power_of_ten() {
936
+ return -27;
937
+ }
938
+
939
+ template <>
940
+ inline constexpr size_t binary_format<std::float16_t>::max_digits() {
941
+ return 22;
942
+ }
943
+ #endif // __STDCPP_FLOAT16_T__
944
+
945
+ // credit: Jakub Jelínek
946
+ #ifdef __STDCPP_BFLOAT16_T__
947
+ template <typename U> struct binary_format_lookup_tables<std::bfloat16_t, U> {
948
+ static constexpr std::bfloat16_t powers_of_ten[] = {1e0bf16, 1e1bf16, 1e2bf16,
949
+ 1e3bf16};
950
+
951
+ // Largest integer value v so that (5**index * v) <= 1<<8.
952
+ // 0x100 == 1<<8
953
+ static constexpr uint64_t max_mantissa[] = {0x100, 0x100 / 5, 0x100 / (5 * 5),
954
+ 0x100 / (5 * 5 * 5),
955
+ 0x100 / (5 * 5 * 5 * 5)};
956
+ };
957
+
958
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
959
+
960
+ template <typename U>
961
+ constexpr std::bfloat16_t
962
+ binary_format_lookup_tables<std::bfloat16_t, U>::powers_of_ten[];
963
+
964
+ template <typename U>
965
+ constexpr uint64_t
966
+ binary_format_lookup_tables<std::bfloat16_t, U>::max_mantissa[];
967
+
968
+ #endif
969
+
970
+ template <>
971
+ inline constexpr std::bfloat16_t
972
+ binary_format<std::bfloat16_t>::exact_power_of_ten(int64_t power) {
973
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
974
+ return (void)powers_of_ten[0], powers_of_ten[power];
975
+ }
976
+
977
+ template <>
978
+ inline constexpr int binary_format<std::bfloat16_t>::max_exponent_fast_path() {
979
+ return 3;
980
+ }
981
+
982
+ template <>
983
+ inline constexpr binary_format<std::bfloat16_t>::equiv_uint
984
+ binary_format<std::bfloat16_t>::exponent_mask() {
985
+ return 0x7F80;
986
+ }
987
+
988
+ template <>
989
+ inline constexpr binary_format<std::bfloat16_t>::equiv_uint
990
+ binary_format<std::bfloat16_t>::mantissa_mask() {
991
+ return 0x007F;
992
+ }
993
+
994
+ template <>
995
+ inline constexpr binary_format<std::bfloat16_t>::equiv_uint
996
+ binary_format<std::bfloat16_t>::hidden_bit_mask() {
997
+ return 0x0080;
998
+ }
999
+
1000
+ template <>
1001
+ inline constexpr int binary_format<std::bfloat16_t>::mantissa_explicit_bits() {
1002
+ return 7;
1003
+ }
1004
+
1005
+ template <>
1006
+ inline constexpr uint64_t
1007
+ binary_format<std::bfloat16_t>::max_mantissa_fast_path() {
1008
+ return uint64_t(2) << mantissa_explicit_bits();
1009
+ }
1010
+
1011
+ template <>
1012
+ inline constexpr uint64_t
1013
+ binary_format<std::bfloat16_t>::max_mantissa_fast_path(int64_t power) {
1014
+ // caller is responsible to ensure that
1015
+ // power >= 0 && power <= 3
1016
+ //
1017
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
1018
+ return (void)max_mantissa[0], max_mantissa[power];
1019
+ }
1020
+
1021
+ template <>
1022
+ inline constexpr int binary_format<std::bfloat16_t>::min_exponent_fast_path() {
1023
+ return 0;
1024
+ }
1025
+
1026
+ template <>
1027
+ inline constexpr int
1028
+ binary_format<std::bfloat16_t>::max_exponent_round_to_even() {
1029
+ return 3;
1030
+ }
1031
+
1032
+ template <>
1033
+ inline constexpr int
1034
+ binary_format<std::bfloat16_t>::min_exponent_round_to_even() {
1035
+ return -24;
1036
+ }
1037
+
1038
+ template <>
1039
+ inline constexpr int binary_format<std::bfloat16_t>::minimum_exponent() {
1040
+ return -127;
1041
+ }
1042
+
1043
+ template <>
1044
+ inline constexpr int binary_format<std::bfloat16_t>::infinite_power() {
1045
+ return 0xFF;
1046
+ }
1047
+
1048
+ template <> inline constexpr int binary_format<std::bfloat16_t>::sign_index() {
1049
+ return 15;
1050
+ }
1051
+
1052
+ template <>
1053
+ inline constexpr int binary_format<std::bfloat16_t>::largest_power_of_ten() {
1054
+ return 38;
1055
+ }
1056
+
1057
+ template <>
1058
+ inline constexpr int binary_format<std::bfloat16_t>::smallest_power_of_ten() {
1059
+ return -60;
1060
+ }
1061
+
1062
+ template <>
1063
+ inline constexpr size_t binary_format<std::bfloat16_t>::max_digits() {
1064
+ return 98;
1065
+ }
1066
+ #endif // __STDCPP_BFLOAT16_T__
1067
+
1068
+ template <>
1069
+ inline constexpr uint64_t
1070
+ binary_format<double>::max_mantissa_fast_path(int64_t power) {
1071
+ // caller is responsible to ensure that
1072
+ // power >= 0 && power <= 22
1073
+ //
1074
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
1075
+ return (void)max_mantissa[0], max_mantissa[power];
1076
+ }
1077
+
1078
+ template <>
1079
+ inline constexpr uint64_t
1080
+ binary_format<float>::max_mantissa_fast_path(int64_t power) {
1081
+ // caller is responsible to ensure that
1082
+ // power >= 0 && power <= 10
1083
+ //
1084
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
1085
+ return (void)max_mantissa[0], max_mantissa[power];
1086
+ }
1087
+
1088
+ template <>
1089
+ inline constexpr double
1090
+ binary_format<double>::exact_power_of_ten(int64_t power) {
1091
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
1092
+ return (void)powers_of_ten[0], powers_of_ten[power];
1093
+ }
1094
+
1095
+ template <>
1096
+ inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) {
1097
+ // Work around clang bug https://godbolt.org/z/zedh7rrhc
1098
+ return (void)powers_of_ten[0], powers_of_ten[power];
1099
+ }
1100
+
1101
+ template <> inline constexpr int binary_format<double>::largest_power_of_ten() {
1102
+ return 308;
1103
+ }
1104
+
1105
+ template <> inline constexpr int binary_format<float>::largest_power_of_ten() {
1106
+ return 38;
1107
+ }
1108
+
1109
+ template <>
1110
+ inline constexpr int binary_format<double>::smallest_power_of_ten() {
1111
+ return -342;
1112
+ }
1113
+
1114
+ template <> inline constexpr int binary_format<float>::smallest_power_of_ten() {
1115
+ return -64;
1116
+ }
1117
+
1118
+ template <> inline constexpr size_t binary_format<double>::max_digits() {
1119
+ return 769;
1120
+ }
1121
+
1122
+ template <> inline constexpr size_t binary_format<float>::max_digits() {
1123
+ return 114;
1124
+ }
1125
+
1126
+ template <>
1127
+ inline constexpr binary_format<float>::equiv_uint
1128
+ binary_format<float>::exponent_mask() {
1129
+ return 0x7F800000;
1130
+ }
1131
+
1132
+ template <>
1133
+ inline constexpr binary_format<double>::equiv_uint
1134
+ binary_format<double>::exponent_mask() {
1135
+ return 0x7FF0000000000000;
1136
+ }
1137
+
1138
+ template <>
1139
+ inline constexpr binary_format<float>::equiv_uint
1140
+ binary_format<float>::mantissa_mask() {
1141
+ return 0x007FFFFF;
1142
+ }
1143
+
1144
+ template <>
1145
+ inline constexpr binary_format<double>::equiv_uint
1146
+ binary_format<double>::mantissa_mask() {
1147
+ return 0x000FFFFFFFFFFFFF;
1148
+ }
1149
+
1150
+ template <>
1151
+ inline constexpr binary_format<float>::equiv_uint
1152
+ binary_format<float>::hidden_bit_mask() {
1153
+ return 0x00800000;
1154
+ }
1155
+
1156
+ template <>
1157
+ inline constexpr binary_format<double>::equiv_uint
1158
+ binary_format<double>::hidden_bit_mask() {
1159
+ return 0x0010000000000000;
1160
+ }
1161
+
1162
+ template <typename T>
1163
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
1164
+ to_float(bool negative, adjusted_mantissa am, T &value) {
1165
+ using equiv_uint = equiv_uint_t<T>;
1166
+ equiv_uint word = equiv_uint(am.mantissa);
1167
+ word = equiv_uint(word | equiv_uint(am.power2)
1168
+ << binary_format<T>::mantissa_explicit_bits());
1169
+ word =
1170
+ equiv_uint(word | equiv_uint(negative) << binary_format<T>::sign_index());
1171
+ #if FASTFLOAT_HAS_BIT_CAST
1172
+ value = std::bit_cast<T>(word);
1173
+ #else
1174
+ ::memcpy(&value, &word, sizeof(T));
1175
+ #endif
1176
+ }
1177
+
1178
+ template <typename = void> struct space_lut {
1179
+ static constexpr bool value[] = {
1180
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1181
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1182
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1183
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1184
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1185
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1186
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1187
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1188
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1189
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1190
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1191
+ };
1192
+
1193
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
1194
+
1195
+ template <typename T> constexpr bool space_lut<T>::value[];
1196
+
1197
+ #endif
1198
+
1199
+ template <typename UC> constexpr bool is_space(UC c) {
1200
+ return c < 256 && space_lut<>::value[uint8_t(c)];
1201
+ }
1202
+
1203
+ template <typename UC> static constexpr uint64_t int_cmp_zeros() {
1204
+ static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
1205
+ "Unsupported character size");
1206
+ return (sizeof(UC) == 1) ? 0x3030303030303030
1207
+ : (sizeof(UC) == 2)
1208
+ ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 |
1209
+ uint64_t(UC('0')) << 16 | UC('0'))
1210
+ : (uint64_t(UC('0')) << 32 | UC('0'));
1211
+ }
1212
+
1213
+ template <typename UC> static constexpr int int_cmp_len() {
1214
+ return sizeof(uint64_t) / sizeof(UC);
1215
+ }
1216
+
1217
+ template <typename UC> constexpr UC const *str_const_nan();
1218
+
1219
+ template <> constexpr char const *str_const_nan<char>() { return "nan"; }
1220
+
1221
+ template <> constexpr wchar_t const *str_const_nan<wchar_t>() { return L"nan"; }
1222
+
1223
+ template <> constexpr char16_t const *str_const_nan<char16_t>() {
1224
+ return u"nan";
1225
+ }
1226
+
1227
+ template <> constexpr char32_t const *str_const_nan<char32_t>() {
1228
+ return U"nan";
1229
+ }
1230
+
1231
+ #ifdef __cpp_char8_t
1232
+ template <> constexpr char8_t const *str_const_nan<char8_t>() {
1233
+ return u8"nan";
1234
+ }
1235
+ #endif
1236
+
1237
+ template <typename UC> constexpr UC const *str_const_inf();
1238
+
1239
+ template <> constexpr char const *str_const_inf<char>() { return "infinity"; }
1240
+
1241
+ template <> constexpr wchar_t const *str_const_inf<wchar_t>() {
1242
+ return L"infinity";
1243
+ }
1244
+
1245
+ template <> constexpr char16_t const *str_const_inf<char16_t>() {
1246
+ return u"infinity";
1247
+ }
1248
+
1249
+ template <> constexpr char32_t const *str_const_inf<char32_t>() {
1250
+ return U"infinity";
1251
+ }
1252
+
1253
+ #ifdef __cpp_char8_t
1254
+ template <> constexpr char8_t const *str_const_inf<char8_t>() {
1255
+ return u8"infinity";
1256
+ }
1257
+ #endif
1258
+
1259
+ template <typename = void> struct int_luts {
1260
+ static constexpr uint8_t chdigit[] = {
1261
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1262
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1263
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1264
+ 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
1265
+ 255, 255, 255, 255, 255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1266
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1267
+ 35, 255, 255, 255, 255, 255, 255, 10, 11, 12, 13, 14, 15, 16, 17,
1268
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
1269
+ 33, 34, 35, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1270
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1271
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1272
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1273
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1274
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1275
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1276
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1277
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1278
+ 255};
1279
+
1280
+ static constexpr size_t maxdigits_u64[] = {
1281
+ 64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16,
1282
+ 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13};
1283
+
1284
+ static constexpr uint64_t min_safe_u64[] = {
1285
+ 9223372036854775808ull, 12157665459056928801ull, 4611686018427387904,
1286
+ 7450580596923828125, 4738381338321616896, 3909821048582988049,
1287
+ 9223372036854775808ull, 12157665459056928801ull, 10000000000000000000ull,
1288
+ 5559917313492231481, 2218611106740436992, 8650415919381337933,
1289
+ 2177953337809371136, 6568408355712890625, 1152921504606846976,
1290
+ 2862423051509815793, 6746640616477458432, 15181127029874798299ull,
1291
+ 1638400000000000000, 3243919932521508681, 6221821273427820544,
1292
+ 11592836324538749809ull, 876488338465357824, 1490116119384765625,
1293
+ 2481152873203736576, 4052555153018976267, 6502111422497947648,
1294
+ 10260628712958602189ull, 15943230000000000000ull, 787662783788549761,
1295
+ 1152921504606846976, 1667889514952984961, 2386420683693101056,
1296
+ 3379220508056640625, 4738381338321616896};
1297
+ };
1298
+
1299
+ #if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
1300
+
1301
+ template <typename T> constexpr uint8_t int_luts<T>::chdigit[];
1302
+
1303
+ template <typename T> constexpr size_t int_luts<T>::maxdigits_u64[];
1304
+
1305
+ template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
1306
+
1307
+ #endif
1308
+
1309
+ template <typename UC>
1310
+ fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) {
1311
+ // wchar_t and char can be signed, so we need to be careful.
1312
+ using UnsignedUC = typename std::make_unsigned<UC>::type;
1313
+ return int_luts<>::chdigit[static_cast<unsigned char>(
1314
+ static_cast<UnsignedUC>(c) &
1315
+ static_cast<UnsignedUC>(
1316
+ -((static_cast<UnsignedUC>(c) & ~0xFFull) == 0)))];
1317
+ }
1318
+
1319
+ fastfloat_really_inline constexpr size_t max_digits_u64(int base) {
1320
+ return int_luts<>::maxdigits_u64[base - 2];
1321
+ }
1322
+
1323
+ // If a u64 is exactly max_digits_u64() in length, this is
1324
+ // the value below which it has definitely overflowed.
1325
+ fastfloat_really_inline constexpr uint64_t min_safe_u64(int base) {
1326
+ return int_luts<>::min_safe_u64[base - 2];
1327
+ }
1328
+
1329
+ static_assert(std::is_same<equiv_uint_t<double>, uint64_t>::value,
1330
+ "equiv_uint should be uint64_t for double");
1331
+ static_assert(std::numeric_limits<double>::is_iec559,
1332
+ "double must fulfill the requirements of IEC 559 (IEEE 754)");
1333
+
1334
+ static_assert(std::is_same<equiv_uint_t<float>, uint32_t>::value,
1335
+ "equiv_uint should be uint32_t for float");
1336
+ static_assert(std::numeric_limits<float>::is_iec559,
1337
+ "float must fulfill the requirements of IEC 559 (IEEE 754)");
1338
+
1339
+ #ifdef __STDCPP_FLOAT64_T__
1340
+ static_assert(std::is_same<equiv_uint_t<std::float64_t>, uint64_t>::value,
1341
+ "equiv_uint should be uint64_t for std::float64_t");
1342
+ static_assert(
1343
+ std::numeric_limits<std::float64_t>::is_iec559,
1344
+ "std::float64_t must fulfill the requirements of IEC 559 (IEEE 754)");
1345
+
1346
+ template <>
1347
+ struct binary_format<std::float64_t> : public binary_format<double> {};
1348
+ #endif // __STDCPP_FLOAT64_T__
1349
+
1350
+ #ifdef __STDCPP_FLOAT32_T__
1351
+ static_assert(std::is_same<equiv_uint_t<std::float32_t>, uint32_t>::value,
1352
+ "equiv_uint should be uint32_t for std::float32_t");
1353
+ static_assert(
1354
+ std::numeric_limits<std::float32_t>::is_iec559,
1355
+ "std::float32_t must fulfill the requirements of IEC 559 (IEEE 754)");
1356
+
1357
+ template <>
1358
+ struct binary_format<std::float32_t> : public binary_format<float> {};
1359
+ #endif // __STDCPP_FLOAT32_T__
1360
+
1361
+ #ifdef __STDCPP_FLOAT16_T__
1362
+ static_assert(
1363
+ std::is_same<binary_format<std::float16_t>::equiv_uint, uint16_t>::value,
1364
+ "equiv_uint should be uint16_t for std::float16_t");
1365
+ static_assert(
1366
+ std::numeric_limits<std::float16_t>::is_iec559,
1367
+ "std::float16_t must fulfill the requirements of IEC 559 (IEEE 754)");
1368
+ #endif // __STDCPP_FLOAT16_T__
1369
+
1370
+ #ifdef __STDCPP_BFLOAT16_T__
1371
+ static_assert(
1372
+ std::is_same<binary_format<std::bfloat16_t>::equiv_uint, uint16_t>::value,
1373
+ "equiv_uint should be uint16_t for std::bfloat16_t");
1374
+ static_assert(
1375
+ std::numeric_limits<std::bfloat16_t>::is_iec559,
1376
+ "std::bfloat16_t must fulfill the requirements of IEC 559 (IEEE 754)");
1377
+ #endif // __STDCPP_BFLOAT16_T__
1378
+
1379
+ constexpr chars_format operator~(chars_format rhs) noexcept {
1380
+ using int_type = std::underlying_type<chars_format>::type;
1381
+ return static_cast<chars_format>(~static_cast<int_type>(rhs));
1382
+ }
1383
+
1384
+ constexpr chars_format operator&(chars_format lhs, chars_format rhs) noexcept {
1385
+ using int_type = std::underlying_type<chars_format>::type;
1386
+ return static_cast<chars_format>(static_cast<int_type>(lhs) &
1387
+ static_cast<int_type>(rhs));
1388
+ }
1389
+
1390
+ constexpr chars_format operator|(chars_format lhs, chars_format rhs) noexcept {
1391
+ using int_type = std::underlying_type<chars_format>::type;
1392
+ return static_cast<chars_format>(static_cast<int_type>(lhs) |
1393
+ static_cast<int_type>(rhs));
1394
+ }
1395
+
1396
+ constexpr chars_format operator^(chars_format lhs, chars_format rhs) noexcept {
1397
+ using int_type = std::underlying_type<chars_format>::type;
1398
+ return static_cast<chars_format>(static_cast<int_type>(lhs) ^
1399
+ static_cast<int_type>(rhs));
1400
+ }
1401
+
1402
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 chars_format &
1403
+ operator&=(chars_format &lhs, chars_format rhs) noexcept {
1404
+ return lhs = (lhs & rhs);
1405
+ }
1406
+
1407
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 chars_format &
1408
+ operator|=(chars_format &lhs, chars_format rhs) noexcept {
1409
+ return lhs = (lhs | rhs);
1410
+ }
1411
+
1412
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 chars_format &
1413
+ operator^=(chars_format &lhs, chars_format rhs) noexcept {
1414
+ return lhs = (lhs ^ rhs);
1415
+ }
1416
+
1417
+ namespace detail {
1418
+ // adjust for deprecated feature macros
1419
+ constexpr chars_format adjust_for_feature_macros(chars_format fmt) {
1420
+ return fmt
1421
+ #ifdef FASTFLOAT_ALLOWS_LEADING_PLUS
1422
+ | chars_format::allow_leading_plus
1423
+ #endif
1424
+ #ifdef FASTFLOAT_SKIP_WHITE_SPACE
1425
+ | chars_format::skip_white_space
1426
+ #endif
1427
+ ;
1428
+ }
1429
+ } // namespace detail
1430
+ } // namespace fast_float
1431
+
1432
+ #endif