Add options for digit separators and prefix skipping

This commit is contained in:
재욱 2026-01-22 17:00:26 +09:00
parent 221a4920db
commit 70aa9a81b1

View File

@ -70,8 +70,10 @@ using from_chars_result = from_chars_result_t<char>;
template <typename UC> struct parse_options_t {
constexpr explicit parse_options_t(chars_format fmt = chars_format::general,
UC dot = UC('.'), int b = 10)
: format(fmt), decimal_point(dot), base(b) {}
UC dot = UC('.'), int b = 10,
UC sep = UC('\0'), uint8_t opts = 0)
: format(fmt), decimal_point(dot), base(b), digit_separator(sep),
format_options(opts) {}
/** Which number formats are accepted */
chars_format format;
@ -79,6 +81,14 @@ template <typename UC> struct parse_options_t {
UC decimal_point;
/** The base used for integers */
int base;
/** The character used as digit separator. Use '\0' to
* disable */
UC digit_separator;
/** Additional format options (bitmask) */
uint8_t format_options;
/** Option to skip prefixes like 0x, 0b */
static constexpr uint8_t skip_prefix = 1;
};
using parse_options = parse_options_t<char>;
@ -199,12 +209,16 @@ using parse_options = parse_options_t<char>;
#ifndef FASTFLOAT_ASSERT
#define FASTFLOAT_ASSERT(x) \
{ ((void)(x)); }
{ \
((void)(x)); \
}
#endif
#ifndef FASTFLOAT_DEBUG_ASSERT
#define FASTFLOAT_DEBUG_ASSERT(x) \
{ ((void)(x)); }
{ \
((void)(x)); \
}
#endif
// rust style `try!()` macro, or `?` operator