Skip to content

Commit 456e4c5

Browse files
committed
Implement prefix skipping in from_chars_advanced
1 parent 4abcd60 commit 456e4c5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

include/fast_float/parse_number.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@ template <typename T, typename UC>
476476
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
477477
from_chars_advanced(UC const *first, UC const *last, T &value,
478478
parse_options_t<UC> options) noexcept {
479+
if ((options.format_options & parse_options_t<UC>::skip_prefix) != 0) {
480+
if ((last - first) >= 2 && *first == UC('0')) {
481+
if ((first[1] == UC('x') || first[1] == UC('X')) ||
482+
(first[1] == UC('b') || first[1] == UC('B'))) {
483+
first += 2;
484+
}
485+
}
486+
}
479487
return from_chars_advanced_caller<
480488
size_t(is_supported_float_type<T>::value) +
481489
2 * size_t(is_supported_integer_type<T>::value)>::call(first, last, value,

0 commit comments

Comments
 (0)