ycpp 0.1.0__cp315-cp315-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.cp315-win_amd64.lib +0 -0
  20. ycpp/_ycpp.cp315-win_amd64.pyd +0 -0
  21. ycpp-0.1.0.data/headers/fast_float/ascii_number.h +766 -0
  22. ycpp-0.1.0.data/headers/fast_float/bigint.h +638 -0
  23. ycpp-0.1.0.data/headers/fast_float/constexpr_feature_detect.h +53 -0
  24. ycpp-0.1.0.data/headers/fast_float/decimal_to_binary.h +212 -0
  25. ycpp-0.1.0.data/headers/fast_float/digit_comparison.h +455 -0
  26. ycpp-0.1.0.data/headers/fast_float/fast_float.h +91 -0
  27. ycpp-0.1.0.data/headers/fast_float/fast_table.h +708 -0
  28. ycpp-0.1.0.data/headers/fast_float/float_common.h +1432 -0
  29. ycpp-0.1.0.data/headers/fast_float/parse_number.h +488 -0
  30. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  31. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
  32. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  33. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  34. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  35. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  36. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  37. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  38. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  39. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  40. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  41. ycpp-0.1.0.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
  42. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
  43. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
  44. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  45. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  46. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  47. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
  48. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  49. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  50. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  51. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  52. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  53. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  54. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  55. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  56. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
  57. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  58. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
  59. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
  60. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  61. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  62. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  63. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
  64. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  65. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
  66. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
  67. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
  68. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
  69. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
  70. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
  71. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
  72. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  73. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  74. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
  75. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
  76. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
  77. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
  78. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
  79. ycpp-0.1.0.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
  80. ycpp-0.1.0.data/headers/xsimd/config/xsimd_config.hpp +620 -0
  81. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
  82. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  83. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  84. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  85. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  86. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
  87. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
  88. ycpp-0.1.0.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
  89. ycpp-0.1.0.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
  90. ycpp-0.1.0.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  91. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  92. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
  93. ycpp-0.1.0.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
  94. ycpp-0.1.0.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
  95. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
  96. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  97. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  98. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  99. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  100. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  101. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  102. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  103. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  104. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  105. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  106. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  107. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
  108. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  109. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
  110. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
  111. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  112. ycpp-0.1.0.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
  113. ycpp-0.1.0.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
  114. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  115. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  116. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  117. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
  118. ycpp-0.1.0.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  119. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
  120. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
  121. ycpp-0.1.0.data/headers/xsimd/types/xsimd_register.hpp +96 -0
  122. ycpp-0.1.0.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
  123. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
  124. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
  125. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  126. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  127. ycpp-0.1.0.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  128. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
  129. ycpp-0.1.0.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
  130. ycpp-0.1.0.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
  131. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
  132. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
  133. ycpp-0.1.0.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
  134. ycpp-0.1.0.data/headers/xsimd/utils/bits.hpp +122 -0
  135. ycpp-0.1.0.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
  136. ycpp-0.1.0.data/headers/xsimd/xsimd.hpp +43 -0
  137. ycpp-0.1.0.dist-info/DELVEWHEEL +2 -0
  138. ycpp-0.1.0.dist-info/METADATA +15 -0
  139. ycpp-0.1.0.dist-info/RECORD +142 -0
  140. ycpp-0.1.0.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,488 @@
1
+ #ifndef FASTFLOAT_PARSE_NUMBER_H
2
+ #define FASTFLOAT_PARSE_NUMBER_H
3
+
4
+ #include "ascii_number.h"
5
+ #include "decimal_to_binary.h"
6
+ #include "digit_comparison.h"
7
+ #include "float_common.h"
8
+
9
+ #include <cmath>
10
+ #include <cstring>
11
+ #include <limits>
12
+ #include <system_error>
13
+
14
+ namespace fast_float {
15
+
16
+ namespace detail {
17
+ /**
18
+ * Special case +inf, -inf, nan, infinity, -infinity.
19
+ * The case comparisons could be made much faster given that we know that the
20
+ * strings a null-free and fixed.
21
+ **/
22
+ template <typename T, typename UC>
23
+ from_chars_result_t<UC>
24
+ FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first, UC const *last,
25
+ T &value, chars_format fmt) noexcept {
26
+ from_chars_result_t<UC> answer{};
27
+ answer.ptr = first;
28
+ answer.ec = std::errc(); // be optimistic
29
+ // assume first < last, so dereference without checks;
30
+ bool const minusSign = (*first == UC('-'));
31
+ // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
32
+ if ((*first == UC('-')) ||
33
+ (uint64_t(fmt & chars_format::allow_leading_plus) &&
34
+ (*first == UC('+')))) {
35
+ ++first;
36
+ }
37
+ if (last - first >= 3) {
38
+ if (fastfloat_strncasecmp3(first, str_const_nan<UC>())) {
39
+ answer.ptr = (first += 3);
40
+ value = minusSign ? -std::numeric_limits<T>::quiet_NaN()
41
+ : std::numeric_limits<T>::quiet_NaN();
42
+ // Check for possible nan(n-char-seq-opt), C++17 20.19.3.7,
43
+ // C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan).
44
+ if (first != last && *first == UC('(')) {
45
+ for (UC const *ptr = first + 1; ptr != last; ++ptr) {
46
+ if (*ptr == UC(')')) {
47
+ answer.ptr = ptr + 1; // valid nan(n-char-seq-opt)
48
+ break;
49
+ } else if (!((UC('a') <= *ptr && *ptr <= UC('z')) ||
50
+ (UC('A') <= *ptr && *ptr <= UC('Z')) ||
51
+ (UC('0') <= *ptr && *ptr <= UC('9')) || *ptr == UC('_')))
52
+ break; // forbidden char, not nan(n-char-seq-opt)
53
+ }
54
+ }
55
+ return answer;
56
+ }
57
+ if (fastfloat_strncasecmp3(first, str_const_inf<UC>())) {
58
+ if ((last - first >= 8) &&
59
+ fastfloat_strncasecmp5(first + 3, str_const_inf<UC>() + 3)) {
60
+ answer.ptr = first + 8;
61
+ } else {
62
+ answer.ptr = first + 3;
63
+ }
64
+ value = minusSign ? -std::numeric_limits<T>::infinity()
65
+ : std::numeric_limits<T>::infinity();
66
+ return answer;
67
+ }
68
+ }
69
+ answer.ec = std::errc::invalid_argument;
70
+ return answer;
71
+ }
72
+
73
+ /**
74
+ * Returns true if the floating-pointing rounding mode is to 'nearest'.
75
+ * It is the default on most system. This function is meant to be inexpensive.
76
+ * Credit : @mwalcott3
77
+ */
78
+ fastfloat_really_inline bool rounds_to_nearest() noexcept {
79
+ // https://lemire.me/blog/2020/06/26/gcc-not-nearest/
80
+ #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
81
+ return false;
82
+ #endif
83
+ // See
84
+ // A fast function to check your floating-point rounding mode
85
+ // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/
86
+ //
87
+ // This function is meant to be equivalent to :
88
+ // prior: #include <cfenv>
89
+ // return fegetround() == FE_TONEAREST;
90
+ // However, it is expected to be much faster than the fegetround()
91
+ // function call.
92
+ //
93
+ // The volatile keyword prevents the compiler from computing the function
94
+ // at compile-time.
95
+ // There might be other ways to prevent compile-time optimizations (e.g.,
96
+ // asm). The value does not need to be std::numeric_limits<float>::min(), any
97
+ // small value so that 1 + x should round to 1 would do (after accounting for
98
+ // excess precision, as in 387 instructions).
99
+ static float volatile fmin = std::numeric_limits<float>::min();
100
+ float fmini = fmin; // we copy it so that it gets loaded at most once.
101
+ //
102
+ // Explanation:
103
+ // Only when fegetround() == FE_TONEAREST do we have that
104
+ // fmin + 1.0f == 1.0f - fmin.
105
+ //
106
+ // FE_UPWARD:
107
+ // fmin + 1.0f > 1
108
+ // 1.0f - fmin == 1
109
+ //
110
+ // FE_DOWNWARD or FE_TOWARDZERO:
111
+ // fmin + 1.0f == 1
112
+ // 1.0f - fmin < 1
113
+ //
114
+ // Note: This may fail to be accurate if fast-math has been
115
+ // enabled, as rounding conventions may not apply.
116
+ #ifdef FASTFLOAT_VISUAL_STUDIO
117
+ #pragma warning(push)
118
+ // todo: is there a VS warning?
119
+ // see
120
+ // https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
121
+ #elif defined(__clang__)
122
+ #pragma clang diagnostic push
123
+ #pragma clang diagnostic ignored "-Wfloat-equal"
124
+ #elif defined(__GNUC__)
125
+ #pragma GCC diagnostic push
126
+ #pragma GCC diagnostic ignored "-Wfloat-equal"
127
+ #endif
128
+ return (fmini + 1.0f == 1.0f - fmini);
129
+ #ifdef FASTFLOAT_VISUAL_STUDIO
130
+ #pragma warning(pop)
131
+ #elif defined(__clang__)
132
+ #pragma clang diagnostic pop
133
+ #elif defined(__GNUC__)
134
+ #pragma GCC diagnostic pop
135
+ #endif
136
+ }
137
+
138
+ } // namespace detail
139
+
140
+ template <typename T> struct from_chars_caller {
141
+ template <typename UC>
142
+ FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
143
+ call(UC const *first, UC const *last, T &value,
144
+ parse_options_t<UC> options) noexcept {
145
+ return from_chars_advanced(first, last, value, options);
146
+ }
147
+ };
148
+
149
+ #ifdef __STDCPP_FLOAT32_T__
150
+ template <> struct from_chars_caller<std::float32_t> {
151
+ template <typename UC>
152
+ FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
153
+ call(UC const *first, UC const *last, std::float32_t &value,
154
+ parse_options_t<UC> options) noexcept {
155
+ // if std::float32_t is defined, and we are in C++23 mode; macro set for
156
+ // float32; set value to float due to equivalence between float and
157
+ // float32_t
158
+ float val;
159
+ auto ret = from_chars_advanced(first, last, val, options);
160
+ value = val;
161
+ return ret;
162
+ }
163
+ };
164
+ #endif
165
+
166
+ #ifdef __STDCPP_FLOAT64_T__
167
+ template <> struct from_chars_caller<std::float64_t> {
168
+ template <typename UC>
169
+ FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
170
+ call(UC const *first, UC const *last, std::float64_t &value,
171
+ parse_options_t<UC> options) noexcept {
172
+ // if std::float64_t is defined, and we are in C++23 mode; macro set for
173
+ // float64; set value as double due to equivalence between double and
174
+ // float64_t
175
+ double val;
176
+ auto ret = from_chars_advanced(first, last, val, options);
177
+ value = val;
178
+ return ret;
179
+ }
180
+ };
181
+ #endif
182
+
183
+ template <typename T, typename UC, typename>
184
+ FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
185
+ from_chars(UC const *first, UC const *last, T &value,
186
+ chars_format fmt /*= chars_format::general*/) noexcept {
187
+ return from_chars_caller<T>::call(first, last, value,
188
+ parse_options_t<UC>(fmt));
189
+ }
190
+
191
+ template <typename T>
192
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool
193
+ clinger_fast_path_impl(uint64_t mantissa, int64_t exponent, bool is_negative,
194
+ T &value) noexcept {
195
+ // The implementation of the Clinger's fast path is convoluted because
196
+ // we want round-to-nearest in all cases, irrespective of the rounding mode
197
+ // selected on the thread.
198
+ // We proceed optimistically, assuming that detail::rounds_to_nearest()
199
+ // returns true.
200
+ if (binary_format<T>::min_exponent_fast_path() <= exponent &&
201
+ exponent <= binary_format<T>::max_exponent_fast_path()) {
202
+ // Unfortunately, the conventional Clinger's fast path is only possible
203
+ // when the system rounds to the nearest float.
204
+ //
205
+ // We expect the next branch to almost always be selected.
206
+ // We could check it first (before the previous branch), but
207
+ // there might be performance advantages at having the check
208
+ // be last.
209
+ if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
210
+ // We have that fegetround() == FE_TONEAREST.
211
+ // Next is Clinger's fast path.
212
+ if (mantissa <= binary_format<T>::max_mantissa_fast_path()) {
213
+ value = T(mantissa);
214
+ if (exponent < 0) {
215
+ value = value / binary_format<T>::exact_power_of_ten(-exponent);
216
+ } else {
217
+ value = value * binary_format<T>::exact_power_of_ten(exponent);
218
+ }
219
+ if (is_negative) {
220
+ value = -value;
221
+ }
222
+ return true;
223
+ }
224
+ } else {
225
+ // We do not have that fegetround() == FE_TONEAREST.
226
+ // Next is a modified Clinger's fast path, inspired by Jakub Jelínek's
227
+ // proposal
228
+ if (exponent >= 0 &&
229
+ mantissa <= binary_format<T>::max_mantissa_fast_path(exponent)) {
230
+ #if defined(__clang__) || defined(FASTFLOAT_32BIT)
231
+ // Clang may map 0 to -0.0 when fegetround() == FE_DOWNWARD
232
+ if (mantissa == 0) {
233
+ value = is_negative ? T(-0.) : T(0.);
234
+ return true;
235
+ }
236
+ #endif
237
+ value = T(mantissa) * binary_format<T>::exact_power_of_ten(exponent);
238
+ if (is_negative) {
239
+ value = -value;
240
+ }
241
+ return true;
242
+ }
243
+ }
244
+ }
245
+ return false;
246
+ }
247
+
248
+ /**
249
+ * This function overload takes parsed_number_string_t structure that is created
250
+ * and populated either by from_chars_advanced function taking chars range and
251
+ * parsing options or other parsing custom function implemented by user.
252
+ */
253
+ template <typename T, typename UC>
254
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
255
+ from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
256
+ static_assert(is_supported_float_type<T>::value,
257
+ "only some floating-point types are supported");
258
+ static_assert(is_supported_char_type<UC>::value,
259
+ "only char, wchar_t, char16_t and char32_t are supported");
260
+
261
+ from_chars_result_t<UC> answer;
262
+
263
+ answer.ec = std::errc(); // be optimistic
264
+ answer.ptr = pns.lastmatch;
265
+
266
+ if (!pns.too_many_digits &&
267
+ clinger_fast_path_impl(pns.mantissa, pns.exponent, pns.negative, value))
268
+ return answer;
269
+
270
+ adjusted_mantissa am =
271
+ compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
272
+ if (pns.too_many_digits && am.power2 >= 0) {
273
+ if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) {
274
+ am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa);
275
+ }
276
+ }
277
+ // If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa)
278
+ // and we have an invalid power (am.power2 < 0), then we need to go the long
279
+ // way around again. This is very uncommon.
280
+ if (am.power2 < 0) {
281
+ am = digit_comp<T>(pns, am);
282
+ }
283
+ to_float(pns.negative, am, value);
284
+ // Test for over/underflow.
285
+ if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
286
+ am.power2 == binary_format<T>::infinite_power()) {
287
+ answer.ec = std::errc::result_out_of_range;
288
+ }
289
+ return answer;
290
+ }
291
+
292
+ template <typename T, typename UC>
293
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
294
+ from_chars_float_advanced(UC const *first, UC const *last, T &value,
295
+ parse_options_t<UC> options) noexcept {
296
+
297
+ static_assert(is_supported_float_type<T>::value,
298
+ "only some floating-point types are supported");
299
+ static_assert(is_supported_char_type<UC>::value,
300
+ "only char, wchar_t, char16_t and char32_t are supported");
301
+
302
+ chars_format const fmt = detail::adjust_for_feature_macros(options.format);
303
+
304
+ from_chars_result_t<UC> answer;
305
+ if (uint64_t(fmt & chars_format::skip_white_space)) {
306
+ while ((first != last) && fast_float::is_space(*first)) {
307
+ first++;
308
+ }
309
+ }
310
+ if (first == last) {
311
+ answer.ec = std::errc::invalid_argument;
312
+ answer.ptr = first;
313
+ return answer;
314
+ }
315
+ parsed_number_string_t<UC> pns =
316
+ uint64_t(fmt & detail::basic_json_fmt)
317
+ ? parse_number_string<true, UC>(first, last, options)
318
+ : parse_number_string<false, UC>(first, last, options);
319
+ if (!pns.valid) {
320
+ if (uint64_t(fmt & chars_format::no_infnan)) {
321
+ answer.ec = std::errc::invalid_argument;
322
+ answer.ptr = first;
323
+ return answer;
324
+ } else {
325
+ return detail::parse_infnan(first, last, value, fmt);
326
+ }
327
+ }
328
+
329
+ // call overload that takes parsed_number_string_t directly.
330
+ return from_chars_advanced(pns, value);
331
+ }
332
+
333
+ template <typename T, typename UC, typename>
334
+ FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
335
+ from_chars(UC const *first, UC const *last, T &value, int base) noexcept {
336
+
337
+ static_assert(is_supported_integer_type<T>::value,
338
+ "only integer types are supported");
339
+ static_assert(is_supported_char_type<UC>::value,
340
+ "only char, wchar_t, char16_t and char32_t are supported");
341
+
342
+ parse_options_t<UC> options;
343
+ options.base = base;
344
+ return from_chars_advanced(first, last, value, options);
345
+ }
346
+
347
+ template <typename T>
348
+ FASTFLOAT_CONSTEXPR20
349
+ typename std::enable_if<is_supported_float_type<T>::value, T>::type
350
+ integer_times_pow10(uint64_t mantissa, int decimal_exponent) noexcept {
351
+ T value;
352
+ if (clinger_fast_path_impl(mantissa, decimal_exponent, false, value))
353
+ return value;
354
+
355
+ adjusted_mantissa am =
356
+ compute_float<binary_format<T>>(decimal_exponent, mantissa);
357
+ to_float(false, am, value);
358
+ return value;
359
+ }
360
+
361
+ template <typename T>
362
+ FASTFLOAT_CONSTEXPR20
363
+ typename std::enable_if<is_supported_float_type<T>::value, T>::type
364
+ integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept {
365
+ const bool is_negative = mantissa < 0;
366
+ const uint64_t m = static_cast<uint64_t>(is_negative ? -mantissa : mantissa);
367
+
368
+ T value;
369
+ if (clinger_fast_path_impl(m, decimal_exponent, is_negative, value))
370
+ return value;
371
+
372
+ adjusted_mantissa am = compute_float<binary_format<T>>(decimal_exponent, m);
373
+ to_float(is_negative, am, value);
374
+ return value;
375
+ }
376
+
377
+ FASTFLOAT_CONSTEXPR20 inline double
378
+ integer_times_pow10(uint64_t mantissa, int decimal_exponent) noexcept {
379
+ return integer_times_pow10<double>(mantissa, decimal_exponent);
380
+ }
381
+
382
+ FASTFLOAT_CONSTEXPR20 inline double
383
+ integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept {
384
+ return integer_times_pow10<double>(mantissa, decimal_exponent);
385
+ }
386
+
387
+ // the following overloads are here to avoid surprising ambiguity for int,
388
+ // unsigned, etc.
389
+ template <typename T, typename Int>
390
+ FASTFLOAT_CONSTEXPR20
391
+ typename std::enable_if<is_supported_float_type<T>::value &&
392
+ std::is_integral<Int>::value &&
393
+ !std::is_signed<Int>::value,
394
+ T>::type
395
+ integer_times_pow10(Int mantissa, int decimal_exponent) noexcept {
396
+ return integer_times_pow10<T>(static_cast<uint64_t>(mantissa),
397
+ decimal_exponent);
398
+ }
399
+
400
+ template <typename T, typename Int>
401
+ FASTFLOAT_CONSTEXPR20
402
+ typename std::enable_if<is_supported_float_type<T>::value &&
403
+ std::is_integral<Int>::value &&
404
+ std::is_signed<Int>::value,
405
+ T>::type
406
+ integer_times_pow10(Int mantissa, int decimal_exponent) noexcept {
407
+ return integer_times_pow10<T>(static_cast<int64_t>(mantissa),
408
+ decimal_exponent);
409
+ }
410
+
411
+ template <typename Int>
412
+ FASTFLOAT_CONSTEXPR20 typename std::enable_if<
413
+ std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
414
+ integer_times_pow10(Int mantissa, int decimal_exponent) noexcept {
415
+ return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
416
+ }
417
+
418
+ template <typename Int>
419
+ FASTFLOAT_CONSTEXPR20 typename std::enable_if<
420
+ std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
421
+ integer_times_pow10(Int mantissa, int decimal_exponent) noexcept {
422
+ return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
423
+ }
424
+
425
+ template <typename T, typename UC>
426
+ FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
427
+ from_chars_int_advanced(UC const *first, UC const *last, T &value,
428
+ parse_options_t<UC> options) noexcept {
429
+
430
+ static_assert(is_supported_integer_type<T>::value,
431
+ "only integer types are supported");
432
+ static_assert(is_supported_char_type<UC>::value,
433
+ "only char, wchar_t, char16_t and char32_t are supported");
434
+
435
+ chars_format const fmt = detail::adjust_for_feature_macros(options.format);
436
+ int const base = options.base;
437
+
438
+ from_chars_result_t<UC> answer;
439
+ if (uint64_t(fmt & chars_format::skip_white_space)) {
440
+ while ((first != last) && fast_float::is_space(*first)) {
441
+ first++;
442
+ }
443
+ }
444
+ if (first == last || base < 2 || base > 36) {
445
+ answer.ec = std::errc::invalid_argument;
446
+ answer.ptr = first;
447
+ return answer;
448
+ }
449
+
450
+ return parse_int_string(first, last, value, options);
451
+ }
452
+
453
+ template <size_t TypeIx> struct from_chars_advanced_caller {
454
+ static_assert(TypeIx > 0, "unsupported type");
455
+ };
456
+
457
+ template <> struct from_chars_advanced_caller<1> {
458
+ template <typename T, typename UC>
459
+ fastfloat_really_inline
460
+ FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
461
+ call(UC const *first, UC const *last, T &value,
462
+ parse_options_t<UC> options) noexcept {
463
+ return from_chars_float_advanced(first, last, value, options);
464
+ }
465
+ };
466
+
467
+ template <> struct from_chars_advanced_caller<2> {
468
+ template <typename T, typename UC>
469
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
470
+ call(UC const *first, UC const *last, T &value,
471
+ parse_options_t<UC> options) noexcept {
472
+ return from_chars_int_advanced(first, last, value, options);
473
+ }
474
+ };
475
+
476
+ template <typename T, typename UC>
477
+ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
478
+ from_chars_advanced(UC const *first, UC const *last, T &value,
479
+ parse_options_t<UC> options) noexcept {
480
+ return from_chars_advanced_caller<
481
+ size_t(is_supported_float_type<T>::value) +
482
+ 2 * size_t(is_supported_integer_type<T>::value)>::call(first, last, value,
483
+ options);
484
+ }
485
+
486
+ } // namespace fast_float
487
+
488
+ #endif