diff --git a/include/fast_io_core_impl/integers/chrono.h b/include/fast_io_core_impl/integers/chrono.h index 065d5763d..d87f008b2 100644 --- a/include/fast_io_core_impl/integers/chrono.h +++ b/include/fast_io_core_impl/integers/chrono.h @@ -136,7 +136,7 @@ inline constexpr parse_result chrono_scan_year_impl(char_type } if (details::char_is_digit<10, char_type>(*itr)) [[unlikely]] { - auto [itr2, ec] = scan_int_contiguous_define_impl<10, true, false, false>(begin, end, retval); + auto [itr2, ec] = scan_int_contiguous_define_impl<10, true, false, false, false>(begin, end, retval); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -198,7 +198,7 @@ chrono_scan_decimal_fraction_part_never_overflow_impl(char_type const *begin, ch { new_end = end; } - auto [itr, ec] = scan_int_contiguous_define_impl<10, true, false, true>(begin, new_end, retval); + auto [itr, ec] = scan_int_contiguous_define_impl<10, true, false, true, false>(begin, new_end, retval); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; diff --git a/include/fast_io_core_impl/integers/impl.h b/include/fast_io_core_impl/integers/impl.h index 6cc823190..22386071b 100644 --- a/include/fast_io_core_impl/integers/impl.h +++ b/include/fast_io_core_impl/integers/impl.h @@ -135,6 +135,7 @@ struct scalar_flags bool showpos{}; bool noskipws{}; bool uppercase_showbase{}; + bool modern_octal{}; bool uppercase{}; bool uppercase_e{}; #if 0 @@ -191,13 +192,14 @@ struct whole_get_t namespace details { -template <::std::size_t bs, bool upper, bool shbase, bool fll, bool showpos = false, bool comma = false, +template <::std::size_t bs, bool upper, bool shbase, bool fll, bool showpos = false, bool comma = false, bool modoct = false, ::fast_io::manipulators::percentage_flag perflag = ::fast_io::manipulators::percentage_flag::none> inline constexpr ::fast_io::manipulators::scalar_flags base_mani_flags_cache{ .base = bs, .showbase = shbase, .showpos = showpos, - .uppercase_showbase = ((bs == 2 || bs == 3 || bs == 16) ? upper : false), + .uppercase_showbase = ((bs == 2 || bs == 3 || (bs == 8 && modoct) || bs == 16) ? upper : false), + .modern_octal = (bs == 8 ? modoct : false), .uppercase = ((bs <= 10) ? false : upper), .comma = comma, .full = fll, @@ -223,9 +225,9 @@ template inline constexpr ::fast_io::manipulators::scalar_flags cryptohash_mani_flags_cache{ .base = 16, .showbase = shbase, .uppercase_showbase = uppercase, .uppercase = uppercase}; -template <::std::size_t bs, bool noskipws, bool shbase, bool skipzero> +template <::std::size_t bs, bool noskipws, bool shbase, bool skipzero, bool modern_octal> inline constexpr ::fast_io::manipulators::scalar_flags base_scan_mani_flags_cache{ - .base = bs, .showbase = shbase, .noskipws = noskipws, .full = skipzero}; + .base = bs, .showbase = shbase, .noskipws = noskipws, .modern_octal = modern_octal, .full = skipzero}; template inline constexpr ::fast_io::manipulators::ip_flags base_ip_prefix_flags_cache{.showport = shport}; @@ -534,20 +536,20 @@ struct width_runtime_ch_t char_type ch; }; -template <::std::size_t bs, bool shbase = false, bool full = false, typename scalar_type> +template <::std::size_t bs, bool shbase = false, bool full = false, bool modern_octal = false, typename scalar_type> requires((2 <= bs && bs <= 36) && (::fast_io::details::scalar_integrals)) inline constexpr auto base(scalar_type t) noexcept { return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache>(t); + ::fast_io::details::base_mani_flags_cache>(t); } -template <::std::size_t bs, bool shbase = false, bool full = false, typename scalar_type> +template <::std::size_t bs, bool shbase = false, bool full = false, bool modern_octal = false, typename scalar_type> requires((2 <= bs && bs <= 36) && (::fast_io::details::scalar_integrals)) inline constexpr auto baseupper(scalar_type t) noexcept { return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache>(t); + ::fast_io::details::base_mani_flags_cache>(t); } template @@ -617,15 +619,6 @@ inline constexpr auto pointervw(scalar_type t) noexcept ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(t); } -template - requires((::std::is_pointer_v || ::std::contiguous_iterator) && - (!::std::is_function_v<::std::remove_cvref_t>)) -inline constexpr auto itervw(scalar_type t) noexcept -{ - return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(t); -} - template requires(::std::is_function_v) inline constexpr auto funcvw(scalar_type *t) noexcept @@ -720,12 +713,12 @@ inline constexpr auto dec(scalar_type t) noexcept ::fast_io::details::base_mani_flags_cache<10, false, shbase, full>>(t); } -template +template requires(::fast_io::details::scalar_integrals) inline constexpr auto oct(scalar_type t) noexcept { return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache<8, false, shbase, full>>(t); + ::fast_io::details::base_mani_flags_cache<8, uppercase_showbase, shbase, full, false, false, modern_octal>>(t); } template @@ -990,7 +983,7 @@ inline constexpr auto generate_base_prefix_array() noexcept template <::std::integral char_type, ::std::size_t base> inline constexpr auto base_prefix_array{generate_base_prefix_array()}; -template <::std::size_t base, bool uppercase_showbase, ::std::integral char_type> +template <::std::size_t base, bool uppercase_showbase, bool modern_octal, ::std::integral char_type> inline constexpr char_type *print_reserve_show_base_impl(char_type *iter) { static_assert(2 <= base && base <= 36); @@ -1094,8 +1087,60 @@ inline constexpr char_type *print_reserve_show_base_impl(char_type *iter) } else if constexpr (base == 8) { - *iter = char_literal_v; - ++iter; + if constexpr (modern_octal) + { + if constexpr (uppercase_showbase) + { + if constexpr (::std::same_as) + { + iter = copy_string_literal("0O", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(L"0O", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(u"0O", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(U"0O", iter); + } + else + { + iter = copy_string_literal(u8"0O", iter); + } + } + else + { + if constexpr (::std::same_as) + { + iter = copy_string_literal("0o", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(L"0o", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(u"0o", iter); + } + else if constexpr (::std::same_as) + { + iter = copy_string_literal(U"0o", iter); + } + else + { + iter = copy_string_literal(u8"0o", iter); + } + } + } + else + { + *iter = char_literal_v; + ++iter; + } } else if constexpr (base == 16) { @@ -1334,12 +1379,12 @@ inline constexpr void print_reserve_integral_withfull_precise_main_impl(char_typ } template <::std::size_t base, bool showbase = false, bool uppercase_showbase = false, bool showpos = false, - bool uppercase = false, bool full = false, typename int_type, ::std::integral char_type> + bool uppercase = false, bool full = false, bool modern_octal = false, typename int_type, ::std::integral char_type> inline constexpr char_type *print_reserve_integral_define(char_type *first, int_type t) { if constexpr (base <= 10 && uppercase) { - return print_reserve_integral_define( + return print_reserve_integral_define( first, t); // prevent duplications } else @@ -1354,7 +1399,7 @@ inline constexpr char_type *print_reserve_integral_define(char_type *first, int_ } if constexpr (showbase && (base != 10)) { - first = print_reserve_show_base_impl(first); + first = print_reserve_show_base_impl(first); } *first = t ? char_literal_v : char_literal_v; ++first; @@ -1400,7 +1445,7 @@ inline constexpr char_type *print_reserve_integral_define(char_type *first, int_ } if constexpr (showbase && (base != 10)) { - first = print_reserve_show_base_impl(first); + first = print_reserve_show_base_impl(first); } return print_reserve_integral_withfull_main_impl(first, u); } @@ -1408,12 +1453,12 @@ inline constexpr char_type *print_reserve_integral_define(char_type *first, int_ } template <::std::size_t base, bool showbase = false, bool uppercase_showbase = false, bool showpos = false, - bool uppercase = false, typename int_type, ::std::integral char_type> + bool uppercase = false, bool modern_octal = false, typename int_type, ::std::integral char_type> inline constexpr void print_reserve_integral_define_precise(char_type *start, ::std::size_t n, int_type t) { if constexpr (base <= 10 && uppercase) { - return print_reserve_integral_define_precise( + return print_reserve_integral_define_precise( start, n, t); // prevent duplications } else @@ -1429,7 +1474,7 @@ inline constexpr void print_reserve_integral_define_precise(char_type *start, :: } if constexpr (showbase && (base != 10)) { - first = print_reserve_show_base_impl(first); + first = print_reserve_show_base_impl(first); } *first = t ? char_literal_v : char_literal_v; ++first; @@ -1475,7 +1520,7 @@ inline constexpr void print_reserve_integral_define_precise(char_type *start, :: } if constexpr (showbase && (base != 10)) { - first = print_reserve_show_base_impl(first); + first = print_reserve_show_base_impl(first); } if constexpr (base == 10 && (::std::numeric_limits<::std::uint_least32_t>::digits == 32u)) { @@ -1498,7 +1543,8 @@ inline constexpr void print_reserve_integral_define_precise(char_type *start, :: } } -inline constexpr ::std::size_t compute_print_showbase_length(::std::size_t base) noexcept +template <::std::size_t base, bool modern_octal> +inline constexpr ::std::size_t compute_print_showbase_length() noexcept { if (base == 2 || base == 3 || base == 16) { @@ -1506,7 +1552,7 @@ inline constexpr ::std::size_t compute_print_showbase_length(::std::size_t base) } else if (base == 8) { - return 1; // 0 + return modern_octal ? 2 : 1; // modern_octal: 0o, default: 0 } else if (base < 10) { @@ -1519,10 +1565,10 @@ inline constexpr ::std::size_t compute_print_showbase_length(::std::size_t base) return 0; } -template <::std::size_t base> -inline constexpr ::std::size_t print_showbase_length{compute_print_showbase_length(base)}; +template <::std::size_t base, bool modern_octal> +inline constexpr ::std::size_t print_showbase_length{compute_print_showbase_length()}; -template <::std::size_t base = 10, bool showbase = false, bool showpos = false, my_integral T> +template <::std::size_t base = 10, bool showbase = false, bool showpos = false, bool modern_octal = false, my_integral T> inline constexpr ::std::size_t print_reserve_scalar_size_impl() { ::std::size_t total_sum{}; @@ -1532,7 +1578,7 @@ inline constexpr ::std::size_t print_reserve_scalar_size_impl() } if constexpr (showbase) { - total_sum += ::fast_io::details::print_showbase_length; + total_sum += ::fast_io::details::print_showbase_length; } if constexpr (::std::same_as<::std::remove_cvref_t, bool>) { @@ -1552,11 +1598,11 @@ inline constexpr ::std::size_t print_reserve_scalar_size_impl() return total_sum; } -template <::std::size_t base, bool showbase, bool showpos, my_integral T> +template <::std::size_t base, bool showbase, bool showpos, bool modern_octal, my_integral T> inline constexpr ::std::size_t print_integer_reserved_size_cache{ - print_reserve_scalar_size_impl()}; + print_reserve_scalar_size_impl()}; -template <::std::size_t base, bool showbase, bool showpos, bool full, my_integral T> +template <::std::size_t base, bool showbase, bool showpos, bool full, bool modern_octal, my_integral T> inline constexpr ::std::size_t print_reserve_scalar_cal_precise_cache_size_impl() { ::std::size_t total_sum{}; @@ -1566,22 +1612,8 @@ inline constexpr ::std::size_t print_reserve_scalar_cal_precise_cache_size_impl( } if constexpr (showbase) { - if constexpr (base == 2 || base == 3 || base == 16) - { - total_sum += 2; // 0b 0t 0x - } - else if constexpr (base == 8) - { - ++total_sum; // 0 - } - else if constexpr (base < 10) - { - total_sum += 4; // 0[9] - } - else if constexpr (10 < base) - { - total_sum += 5; // 0[36] - } + constexpr auto curr_length{::fast_io::details::print_showbase_length}; + total_sum += curr_length; // base==10 does not have showbase if constexpr (full) { @@ -1605,22 +1637,22 @@ inline constexpr ::std::size_t print_reserve_scalar_cal_precise_cache_size_impl( return total_sum; } -template <::std::size_t base, bool showbase, bool showpos, bool full, my_integral T> +template <::std::size_t base, bool showbase, bool showpos, bool full, bool modern_octal, my_integral T> inline constexpr ::std::size_t print_integer_reserved_precise_size_cache{ - print_reserve_scalar_cal_precise_cache_size_impl()}; + print_reserve_scalar_cal_precise_cache_size_impl()}; -template <::std::size_t base, bool showbase, bool showpos, bool full, my_integral T> +template <::std::size_t base, bool showbase, bool showpos, bool full, bool modern_octal, my_integral T> inline constexpr ::std::size_t print_integer_reserved_precise_size(T t) { if constexpr (::std::same_as<::std::remove_cvref_t, bool>) { - return print_integer_reserved_size_cache; + return print_integer_reserved_size_cache; } else if constexpr (full) { if constexpr (!showpos && my_signed_integral) { - ::std::size_t total_sum{print_integer_reserved_precise_size_cache}; + ::std::size_t total_sum{print_integer_reserved_precise_size_cache}; if (t < 0) { ++total_sum; @@ -1629,12 +1661,12 @@ inline constexpr ::std::size_t print_integer_reserved_precise_size(T t) } else { - return print_integer_reserved_precise_size_cache; + return print_integer_reserved_precise_size_cache; } } else { - ::std::size_t total_sum{print_integer_reserved_precise_size_cache}; + ::std::size_t total_sum{print_integer_reserved_precise_size_cache}; if constexpr (my_signed_integral) { using unsigned_type = my_make_unsigned_t; @@ -1655,38 +1687,39 @@ inline constexpr ::std::size_t print_integer_reserved_precise_size(T t) } template <::std::integral char_type, ::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, - bool uppercase, bool full> + bool uppercase, bool full, bool modern_octal> inline constexpr ::std::size_t nullptr_print_optimization_call_size_impl() noexcept { - ::fast_io::freestanding::array> + ::fast_io::freestanding::array> arr; - auto res{print_reserve_integral_define( + auto res{print_reserve_integral_define( arr.data(), ::std::size_t{})}; return static_cast<::std::size_t>(res - arr.data()); } template <::std::integral char_type, ::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, - bool uppercase, bool full> + bool uppercase, bool full, bool modern_octal> inline constexpr ::std::size_t nullptr_print_optimization_call_size_cache{ nullptr_print_optimization_call_size_impl()}; + full, modern_octal>()}; template <::std::integral char_type, ::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, - bool uppercase, bool full> + bool uppercase, bool full, bool modern_octal> inline constexpr auto nullptr_print_optimization_call_impl() noexcept { constexpr ::std::size_t sz{nullptr_print_optimization_call_size_cache}; + showpos, uppercase, full, modern_octal>}; ::fast_io::freestanding::array arr{}; - [[maybe_unused]] auto res{print_reserve_integral_define( + [[maybe_unused]] auto res{print_reserve_integral_define( arr.data(), ::std::size_t{})}; return arr; } template <::std::integral char_type, ::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, - bool uppercase, bool full> + bool uppercase, bool full, bool modern_octal> inline constexpr auto nullptr_print_optimization_call_cache{ - nullptr_print_optimization_call_impl()}; + nullptr_print_optimization_call_impl()}; template inline constexpr char_type *print_reserve_boolalpha_impl(char_type *iter, bool b) @@ -1870,13 +1903,13 @@ inline constexpr char_type *print_reserve_nullptr_alphabet_impl(char_type *iter) } template <::std::size_t base, bool showbase = false, bool uppercase_showbase = false, bool showpos = false, - bool uppercase = false, bool full = false, ::std::integral char_type> + bool uppercase = false, bool full = false, bool modern_octal = false, ::std::integral char_type> inline constexpr char_type *print_reserve_method_impl(char_type *iter, ::fast_io::manipulators::member_function_pointer_holder_t mfph) { if constexpr (base <= 10 && uppercase) { - return print_reserve_method_impl( + return print_reserve_method_impl( iter, mfph); // prevent duplications } else if constexpr (::fast_io::details::method_ptr_hold_size == 0) @@ -1885,13 +1918,13 @@ inline constexpr char_type *print_reserve_method_impl(char_type *iter, } else { - iter = details::print_reserve_integral_define( + iter = details::print_reserve_integral_define( iter, mfph.reference.front()); using myssizet = ::std::make_signed_t<::std::size_t>; if constexpr (::fast_io::details::method_ptr_hold_size == 2) { ::std::size_t backptr{mfph.reference.back()}; - return details::print_reserve_integral_define( + return details::print_reserve_integral_define( iter, static_cast(backptr)); } else @@ -1901,7 +1934,7 @@ inline constexpr char_type *print_reserve_method_impl(char_type *iter, for (::std::size_t i{1}; i != last; ++i) { iter = - details::print_reserve_integral_define( + details::print_reserve_integral_define( iter, static_cast(mfph.reference[i])); } return iter; @@ -1945,11 +1978,11 @@ inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t, ::std::byte>) { - return details::print_integer_reserved_size_cache<10, false, false, char8_t>; + return details::print_integer_reserved_size_cache<10, false, false, false, char8_t>; } else { - return details::print_integer_reserved_size_cache<10, false, false, ::std::remove_cvref_t>; + return details::print_integer_reserved_size_cache<10, false, false, false, ::std::remove_cvref_t>; } } @@ -1996,7 +2029,7 @@ print_reserve_size(io_reserve_type_t, ::fast_io::manipulators::member_function_pointer_holder_t>) { constexpr ::std::size_t method_size{ - (details::print_integer_reserved_size_cache + 1) * + (details::print_integer_reserved_size_cache + 1) * ::fast_io::details::method_ptr_hold_size - 1}; return method_size; @@ -2005,15 +2038,15 @@ print_reserve_size(io_reserve_type_t; + flags.uppercase, flags.full, flags.modern_octal>; } else if constexpr (::std::same_as<::std::remove_cv_t, ::std::byte>) { - return details::print_integer_reserved_size_cache; + return details::print_integer_reserved_size_cache; } else { - return details::print_integer_reserved_size_cache; + return details::print_integer_reserved_size_cache; } } @@ -2046,27 +2079,27 @@ print_reserve_define(io_reserve_type_t, ::fast_io::manipulators::member_function_pointer_holder_t>) { return ::fast_io::details::print_reserve_method_impl(iter, - t.reference); + flags.showpos, flags.uppercase, flags.full, flags.modern_octal>(iter, + t.reference); } else if constexpr (::std::same_as<::std::remove_cv_t, ::std::nullptr_t>) { constexpr auto &cache{details::nullptr_print_optimization_call_cache}; + flags.uppercase, flags.full, flags.modern_octal>}; constexpr ::std::size_t n{cache.size()}; return details::non_overlapped_copy_n(cache.element, n, iter); } else if constexpr (::std::same_as<::std::remove_cv_t, ::std::byte>) { return details::print_reserve_integral_define( + flags.showpos, flags.uppercase, flags.full, flags.modern_octal>( iter, static_cast(t.reference)); } else { return details::print_reserve_integral_define(iter, t.reference); + flags.showpos, flags.uppercase, flags.full, flags.modern_octal>(iter, t.reference); } } @@ -2078,13 +2111,13 @@ print_reserve_precise_size(io_reserve_type_t) { - return details::print_integer_reserved_precise_size( - static_cast(t.reference)); + return details::print_integer_reserved_precise_size(static_cast(t.reference)); } else { - return details::print_integer_reserved_precise_size( - t.reference); + return details::print_integer_reserved_precise_size(t.reference); } } @@ -2097,13 +2130,13 @@ inline constexpr void print_reserve_precise_define(io_reserve_type_t) { details::print_reserve_integral_define_precise( + flags.showpos, flags.uppercase, flags.modern_octal>( iter, n, static_cast(t.reference)); } else { details::print_reserve_integral_define_precise(iter, n, t.reference); + flags.showpos, flags.uppercase, flags.modern_octal>(iter, n, t.reference); } } diff --git a/include/fast_io_core_impl/integers/ordinal.h b/include/fast_io_core_impl/integers/ordinal.h index e1b950d77..76189d54c 100644 --- a/include/fast_io_core_impl/integers/ordinal.h +++ b/include/fast_io_core_impl/integers/ordinal.h @@ -24,10 +24,12 @@ inline constexpr auto ordinal(T t) noexcept namespace details { -template <::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, bool uppercase, bool full, ::std::integral char_type, typename T> +template <::std::size_t base, bool showbase, bool uppercase_showbase, bool showpos, bool uppercase, bool full, + bool modern_octal, ::std::integral char_type, typename T> inline constexpr char_type *prrsv_ordinal_impl(char_type *iter, T t) noexcept { - iter = ::fast_io::details::print_reserve_integral_define(iter, t); + iter = ::fast_io::details::print_reserve_integral_define(iter, t); std::uint_least8_t prefix_kind{}; if (t / 100 % 10 == 1) { @@ -78,13 +80,16 @@ inline constexpr char_type *prrsv_ordinal_impl(char_type *iter, T t) noexcept template <::std::integral char_type, ::fast_io::manipulators::scalar_flags flags, ::fast_io::details::my_integral T> inline constexpr ::std::size_t print_reserve_size(::fast_io::io_reserve_type_t>>) { - return ::fast_io::details::print_integer_reserved_size_cache + 2u; + return ::fast_io::details::print_integer_reserved_size_cache + + 2u; } template <::std::integral char_type, ::fast_io::manipulators::scalar_flags flags, typename T> inline constexpr char_type *print_reserve_define(::fast_io::io_reserve_type_t>>, char_type *iter, ::fast_io::manipulators::scalar_manip_t> t) noexcept { - return ::fast_io::details::prrsv_ordinal_impl(iter, t.reference.reference); + return ::fast_io::details::prrsv_ordinal_impl(iter, + t.reference.reference); } } // namespace fast_io diff --git a/include/fast_io_core_impl/integers/percentage.h b/include/fast_io_core_impl/integers/percentage.h index 5a26db32b..fca0c79da 100644 --- a/include/fast_io_core_impl/integers/percentage.h +++ b/include/fast_io_core_impl/integers/percentage.h @@ -32,7 +32,7 @@ template , ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -44,7 +44,7 @@ template , ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -52,12 +52,12 @@ inline constexpr auto comma_percentage_conventional(T num, U deno) noexcept } template <::std::size_t base, bool upper = false, bool shbase = false, bool fll = false, bool showpos = false, - typename T, typename U> + bool modern_octal = false, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr auto base_percentage_conventional(T num, U deno) noexcept { return ::fast_io::manipulators::scalar_manip_t< - ::fast_io::details::base_mani_flags_cache, ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -65,12 +65,12 @@ inline constexpr auto base_percentage_conventional(T num, U deno) noexcept } template <::std::size_t base, bool upper = false, bool shbase = false, bool fll = false, bool showpos = false, - typename T, typename U> + bool modern_octal = false, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr auto comma_base_percentage_conventional(T num, U deno) noexcept { return ::fast_io::manipulators::scalar_manip_t< - ::fast_io::details::base_mani_flags_cache, ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -88,7 +88,7 @@ template , ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -100,7 +100,7 @@ template , ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -108,12 +108,12 @@ inline constexpr auto comma_percentage_sex_ratio(T male, U female) noexcept } template <::std::size_t base, bool upper = false, bool shbase = false, bool fll = false, bool showpos = false, - typename T, typename U> + bool modern_octal = false, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr auto base_percentage_sex_ratio(T male, U female) noexcept { return ::fast_io::manipulators::scalar_manip_t< - ::fast_io::details::base_mani_flags_cache, ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -121,12 +121,12 @@ inline constexpr auto base_percentage_sex_ratio(T male, U female) noexcept } template <::std::size_t base, bool upper = false, bool shbase = false, bool fll = false, bool showpos = false, - typename T, typename U> + bool modern_octal = false, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr auto comma_base_percentage_sex_ratio(T male, U female) noexcept { return ::fast_io::manipulators::scalar_manip_t< - ::fast_io::details::base_mani_flags_cache, ::fast_io::manipulators::percentage_conventional_t< typename ::fast_io::details::integer_alias_type_traits::alias_type, @@ -143,7 +143,7 @@ inline constexpr ::std::size_t print_reserve_size( flags, ::fast_io::manipulators::percentage_conventional_t>>) noexcept { constexpr auto val{ - ::fast_io::details::print_integer_reserved_size_cache + 5u}; + ::fast_io::details::print_integer_reserved_size_cache + 5u}; if constexpr (flags.percentage == ::fast_io::manipulators::percentage_flag::percent) { return val + 1u; @@ -155,7 +155,7 @@ inline constexpr ::std::size_t print_reserve_size( if constexpr (flags.showbase) { constexpr ::std::size_t sexratioshowbase{percentagesexratiocommonsize + - ::fast_io::details::print_showbase_length}; + ::fast_io::details::print_showbase_length}; return sexratioshowbase; } else @@ -189,16 +189,16 @@ template <::std::size_t base, typename T> requires(2 <= base && base <= 36) inline constexpr T base_ul64_max_val{::fast_io::details::compute_base_ul64_max_val()}; -template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool comma, +template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool comma, bool modern_octal, ::std::integral chartype, typename T, typename U> requires(::fast_io::details::my_unsigned_integral && ::fast_io::details::my_unsigned_integral) inline constexpr chartype *prrsv_percentage_main_common_impl(chartype *iter, T numerator, U denominator) noexcept { if constexpr (showbase) { - iter = print_reserve_show_base_impl(iter); - return prrsv_percentage_main_common_impl(iter, numerator, - denominator); + iter = print_reserve_show_base_impl(iter); + return prrsv_percentage_main_common_impl( + iter, numerator, denominator); } else { @@ -229,7 +229,8 @@ inline constexpr chartype *prrsv_percentage_main_common_impl(chartype *iter, T n else { iter = ::fast_io::details::print_reserve_integral_define(iter, quotientdiv100); + uppercase, full, modern_octal>(iter, + quotientdiv100); } *iter = ::fast_io::char_literal_v<(comma ? u8',' : u8'.'), chartype>; ++iter; @@ -284,7 +285,8 @@ inline constexpr chartype *prrsv_percentage_main_common_impl(chartype *iter, T n auto quotientdiv100{quotient / twodigits}; quotientmod100 = static_cast(quotient % twodigits); iter = ::fast_io::details::print_reserve_integral_define(iter, quotientdiv100); + uppercase, full, modern_octal>(iter, + quotientdiv100); } else { @@ -309,7 +311,8 @@ inline constexpr chartype *prrsv_percentage_main_common_impl(chartype *iter, T n auto quotientdiv100{quotientlow / twodigits}; quotientmod100 = static_cast(quotientlow % twodigits); iter = ::fast_io::details::print_reserve_integral_define(iter, quotientdiv100); + uppercase, full, modern_octal>( + iter, quotientdiv100); } else { @@ -330,7 +333,8 @@ inline constexpr chartype *prrsv_percentage_main_common_impl(chartype *iter, T n { iter = ::fast_io::details::print_reserve_integral_define(iter, quotientlowlow); + uppercase, full, modern_octal>( + iter, quotientlowlow); } auto quotientdiv100{remainderlowlow / twodigits}; quotientmod100 = static_cast(remainderlowlow % twodigits); @@ -454,13 +458,13 @@ inline constexpr chartype *prrsv_percentage_denominatorzero_impl(chartype *iter) } template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool showpos, - bool comma, ::std::integral chartype, typename T> + bool comma, bool modern_octal, ::std::integral chartype, typename T> requires(::fast_io::details::my_integral) inline constexpr chartype *prrsv_percentage_denominatorzero_sexratio_impl(chartype *iter, T numerator) noexcept { iter = - ::fast_io::details::print_reserve_integral_define( - iter, numerator); + ::fast_io::details::print_reserve_integral_define(iter, numerator); if constexpr (showbase && base != 10) { if constexpr (comma) @@ -561,7 +565,7 @@ inline constexpr chartype *prrsv_percentage_denominatorzero_sexratio_impl(charty } } } - iter = ::fast_io::details::print_reserve_show_base_impl(iter); + iter = ::fast_io::details::print_reserve_show_base_impl(iter); *iter = ::fast_io::char_literal_v; ++iter; } @@ -670,7 +674,7 @@ inline constexpr chartype *prrsv_percentage_denominatorzero_sexratio_impl(charty } template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool showpos, - bool comma, ::std::integral chartype, typename T, typename U> + bool comma, bool modern_octal, ::std::integral chartype, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr chartype *prrsv_percentage_sexratio_signed_impl(chartype *iter, T numerator, U denominator, bool denominatorisnegative) noexcept @@ -678,12 +682,14 @@ inline constexpr chartype *prrsv_percentage_sexratio_signed_impl(chartype *iter, if constexpr (sizeof(T) < sizeof(::std::uint_least32_t) && !full) { return prrsv_percentage_sexratio_signed_impl(iter, static_cast<::std::uint_least32_t>(numerator), - denominator, denominatorisnegative); + comma, modern_octal>(iter, + static_cast<::std::uint_least32_t>(numerator), + denominator, denominatorisnegative); } else { - iter = prrsv_percentage_main_common_impl( + iter = prrsv_percentage_main_common_impl( iter, numerator, denominator); *iter = ::fast_io::char_literal_v; ++iter; @@ -703,7 +709,7 @@ inline constexpr chartype *prrsv_percentage_sexratio_signed_impl(chartype *iter, } if constexpr (showbase && base != 10) { - iter = ::fast_io::details::print_reserve_show_base_impl(iter); + iter = ::fast_io::details::print_reserve_show_base_impl(iter); } if constexpr (::std::same_as) { @@ -730,11 +736,11 @@ inline constexpr chartype *prrsv_percentage_sexratio_signed_impl(chartype *iter, } template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool showpos, - bool comma, ::std::integral chartype, typename T, typename U> + bool comma, bool modern_octal, ::std::integral chartype, typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr chartype *prrsv_percentage_sexratio_unsigned_impl(chartype *iter, T numerator, U denominator) noexcept { - iter = prrsv_percentage_main_common_impl( + iter = prrsv_percentage_main_common_impl( iter, numerator, denominator); *iter = ::fast_io::char_literal_v; ++iter; @@ -745,7 +751,7 @@ inline constexpr chartype *prrsv_percentage_sexratio_unsigned_impl(chartype *ite } if constexpr (showbase && base != 10) { - iter = ::fast_io::details::print_reserve_show_base_impl(iter); + iter = ::fast_io::details::print_reserve_show_base_impl(iter); } if constexpr (::std::same_as) { @@ -771,8 +777,8 @@ inline constexpr chartype *prrsv_percentage_sexratio_unsigned_impl(chartype *ite } template <::std::size_t base, bool uppercase, bool showbase, bool uppercase_showbase, bool full, bool showpos, - bool comma, ::fast_io::manipulators::percentage_flag percent, ::std::integral chartype, typename T, - typename U> + bool comma, bool modern_octal, ::fast_io::manipulators::percentage_flag percent, ::std::integral chartype, + typename T, typename U> requires(::fast_io::details::my_integral && ::fast_io::details::my_integral) inline constexpr chartype *prrsv_percentage_conventional_impl(chartype *iter, T numerator, U denominator) noexcept { @@ -783,7 +789,7 @@ inline constexpr chartype *prrsv_percentage_conventional_impl(chartype *iter, T if constexpr (::fast_io::manipulators::percentage_flag::sexratio == percent) { return prrsv_percentage_denominatorzero_sexratio_impl(iter, numerator); + showpos, comma, modern_octal>(iter, numerator); } else { @@ -847,29 +853,31 @@ inline constexpr chartype *prrsv_percentage_conventional_impl(chartype *iter, T ::fast_io::details::my_signed_integral) { return prrsv_percentage_sexratio_signed_impl(iter, unsignednum, unsignedden, denominatorisnegative); + comma, modern_octal>(iter, unsignednum, unsignedden, + denominatorisnegative); } else { return prrsv_percentage_conventional_impl(iter, unsignednum, unsignedden); + comma, modern_octal, percent>(iter, unsignednum, unsignedden); } } else if constexpr (sizeof(T) < sizeof(::std::uint_least32_t) && !full) { return prrsv_percentage_conventional_impl(iter, static_cast<::std::uint_least32_t>(numerator), - denominator); + modern_octal, percent>( + iter, static_cast<::std::uint_least32_t>(numerator), denominator); } else if constexpr (percent == ::fast_io::manipulators::percentage_flag::sexratio) { return prrsv_percentage_sexratio_unsigned_impl(iter, numerator, denominator); + comma, modern_octal>(iter, numerator, denominator); } else { iter = ::fast_io::details::prrsv_percentage_main_common_impl(iter, numerator, denominator); + full, comma, modern_octal>(iter, numerator, + denominator); if constexpr (percent == ::fast_io::manipulators::percentage_flag::percent) { *iter = ::fast_io::char_literal_v; @@ -891,7 +899,7 @@ inline constexpr chartype *print_reserve_define( { return ::fast_io::details::prrsv_percentage_conventional_impl( + flags.comma, flags.modern_octal, flags.percentage>( iter, v.reference.numerator, v.reference.denominator); } diff --git a/include/fast_io_core_impl/integers/sto/sto_contiguous.h b/include/fast_io_core_impl/integers/sto/sto_contiguous.h index e0a9c1fb9..dc3966efc 100644 --- a/include/fast_io_core_impl/integers/sto/sto_contiguous.h +++ b/include/fast_io_core_impl/integers/sto/sto_contiguous.h @@ -257,8 +257,8 @@ struct simd_parse_result inline constexpr char unsigned simd16_shift_table[32]{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - -#if defined(__SSE4_1__) && (defined(__x86_64__) || defined(_M_AMD64)) +// aarch64ec also defines x86_64 macro +#if defined(__SSE4_1__) && ((defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) && !(defined(__arm64ec__) || defined(_M_ARM64EC))) template inline ::std::uint_least32_t detect_length(char unsigned const *buffer) noexcept @@ -945,7 +945,7 @@ scan_int_contiguous_none_simd_space_part_define_impl(char_type const *first, cha inline constexpr parse_code ongoing_parse_code{static_cast(::std::numeric_limits::max())}; -template +template inline constexpr parse_result scan_shbase_impl(char_type const *first, char_type const *last) noexcept { @@ -957,11 +957,11 @@ inline constexpr parse_result scan_shbase_impl(char_type cons { return {first, parse_code::invalid}; } - if constexpr (base == 2 || base == 3 || base == 16) + if constexpr (base == 2 || base == 3 || (base == 8 && modern_octal) || base == 16) { auto ch{*first}; - if ((ch != char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : u8'X')), char_type>)&( - ch != char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) [[unlikely]] + if ((ch != char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : (base == 8 ? u8'O' : u8'X'))), char_type>)&( + ch != char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : (base == 8 ? u8'o' : u8'x'))), char_type>)) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1010,7 +1010,7 @@ inline constexpr parse_result scan_shbase_impl(char_type cons template <::std::integral char_type> inline constexpr char_type const *skip_hexdigits(char_type const *first, char_type const *last) noexcept; -template +template inline constexpr parse_result scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_type const *last, T &t) noexcept { @@ -1029,7 +1029,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ } if constexpr (shbase && base != 10) { - if constexpr (base == 8) + if constexpr (base == 8 && !modern_octal) { if (first == last || *first != char_literal_v) [[unlikely]] { @@ -1039,7 +1039,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ } else { - auto phase_ret = scan_shbase_impl(first, last); + auto phase_ret = scan_shbase_impl(first, last); if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; @@ -1083,7 +1083,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ using unsigned_type = my_make_unsigned_t<::std::remove_cvref_t>; unsigned_type res{}; char_type const *it; -#if defined(__SSE4_1__) && (defined(__x86_64__) || defined(_M_AMD64)) +#if defined(__SSE4_1__) && ((defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) && !(defined(__arm64ec__) || defined(_M_ARM64EC))) if constexpr (base == 10 && sizeof(char_type) == 1 && sizeof(unsigned_type) <= sizeof(::std::uint_least64_t)) { if ( @@ -1159,7 +1159,8 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ return {it, parse_code::ok}; } -template +template inline constexpr parse_result scan_int_contiguous_define_impl(char_type const *first, char_type const *last, T &t) noexcept { @@ -1175,7 +1176,7 @@ inline constexpr parse_result scan_int_contiguous_define_impl { if constexpr (shbase && base != 10) { - if constexpr (base == 8) + if constexpr (base == 8 && !modern_octal) { if (first == last || *first != char_literal_v) [[unlikely]] { @@ -1185,7 +1186,7 @@ inline constexpr parse_result scan_int_contiguous_define_impl } else { - auto phase_ret = scan_shbase_impl(first, last); + auto phase_ret = scan_shbase_impl(first, last); if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; @@ -1195,7 +1196,7 @@ inline constexpr parse_result scan_int_contiguous_define_impl } } return scan_int_contiguous_none_space_part_define_impl), - skipzero>(first, last, t); + skipzero, modern_octal>(first, last, t); } } // namespace details @@ -1219,7 +1220,7 @@ inline constexpr auto scan_context_type_impl_int() noexcept using unsigned_type = details::my_make_unsigned_t<::std::remove_cvref_t>; constexpr ::std::size_t max_size{ (::fast_io::details::print_integer_reserved_size_cache, - unsigned_type>)+2}; + false, unsigned_type>) + 2}; struct scan_integer_context { ::fast_io::freestanding::array buffer; @@ -1299,7 +1300,7 @@ inline constexpr parse_result sc_int_ctx_sign_phase(State &st return {first, ongoing_parse_code}; } -template +template requires(base != 10) inline constexpr parse_result sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_type const *last) noexcept @@ -1308,7 +1309,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t { return {first, parse_code::partial}; } - if constexpr (base == 8) + if constexpr (base == 8 && !modern_octal) { if (*first != char_literal_v) [[unlikely]] { @@ -1334,11 +1335,11 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t size_cache = 1; } } - if constexpr (base == 2 || base == 3 || base == 16) + if constexpr (base == 2 || base == 3 || (base == 8 && modern_octal) || base == 16) { auto ch{*first}; - if ((ch == char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : u8'X')), char_type>) | - (ch == char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) [[likely]] + if ((ch == char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : (base == 8 ? u8'O' : u8'X'))), char_type>) | + (ch == char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : (base == 8 ? u8'o' : u8'x'))), char_type>)) [[likely]] { sz = 0; ++first; @@ -1455,7 +1456,7 @@ inline constexpr parse_result sc_int_ctx_zero_phase(scan_inte return {first, ongoing_parse_code}; } -template +template inline constexpr parse_result sc_int_ctx_digit_phase(State &st, char_type const *first, char_type const *last, T &t) noexcept { @@ -1477,7 +1478,7 @@ inline constexpr parse_result sc_int_ctx_digit_phase(State &s t = {}; return {it, parse_code::ok}; } - auto [p, ec] = scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), e, t); + auto [p, ec] = scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), e, t); return {p - start + first, ec}; } else @@ -1519,8 +1520,8 @@ inline constexpr parse_result sc_int_ctx_skip_digits_phase(ch return {first, (first == last) ? parse_code::partial : parse_code::invalid}; } -template +template inline constexpr parse_result scan_context_define_parse_impl(State &st, char_type const *first, char_type const *last, T &t) noexcept { @@ -1580,7 +1581,7 @@ inline constexpr parse_result scan_context_define_parse_impl( if constexpr (shbase && base != 10) { st.integer_phase = scan_integral_context_phase::prefix; - auto phase_ret = sc_int_ctx_prefix_phase(st.size, first, last); + auto phase_ret = sc_int_ctx_prefix_phase(st.size, first, last); if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; @@ -1621,7 +1622,7 @@ inline constexpr parse_result scan_context_define_parse_impl( } case scan_integral_context_phase::digit: { - return sc_int_ctx_digit_phase(st, first, last, t); + return sc_int_ctx_digit_phase(st, first, last, t); } case scan_integral_context_phase::zero_invalid: { @@ -1646,7 +1647,7 @@ inline constexpr parse_result scan_context_define_parse_impl( } } -template +template #if __has_cpp_attribute(__gnu__::__cold__) [[__gnu__::__cold__]] #endif @@ -1673,7 +1674,7 @@ inline constexpr parse_code scan_context_eof_define_parse_impl(State &st, T &t) } } case scan_integral_context_phase::digit: - return scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), st.buffer.data() + st.size, t).code; + return scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), st.buffer.data() + st.size, t).code; case scan_integral_context_phase::overflow: return parse_code::overflow; case scan_integral_context_phase::zero_skip: @@ -1705,9 +1706,10 @@ inline constexpr ch_get_t ch_get(T &reference) noexcept return {reference}; } -template <::std::size_t bs, bool noskipws = false, bool skipzero = false, bool prefix = false, ::fast_io::details::my_integral scalar_type> +template <::std::size_t bs, bool noskipws = false, bool skipzero = false, bool prefix = false, bool modern_octal = false, + ::fast_io::details::my_integral scalar_type> requires(2 <= bs && bs <= 36) -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache, +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache, scalar_type &> base_get(scalar_type &t) noexcept { @@ -1715,15 +1717,15 @@ base_get(scalar_type &t) noexcept } template -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<2, noskipws, prefix, skipzero>, +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<2, noskipws, prefix, skipzero, false>, scalar_type &> bin_get(scalar_type &t) noexcept { return {t}; } -template -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<8, noskipws, prefix, skipzero>, +template +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<8, noskipws, prefix, skipzero, modern_octal>, scalar_type &> oct_get(scalar_type &t) noexcept { @@ -1731,7 +1733,7 @@ oct_get(scalar_type &t) noexcept } template -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<10, noskipws, false, skipzero>, +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<10, noskipws, false, skipzero, false>, scalar_type &> dec_get(scalar_type &t) noexcept { @@ -1739,7 +1741,7 @@ dec_get(scalar_type &t) noexcept } template -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<16, noskipws, prefix, skipzero>, +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<16, noskipws, prefix, skipzero, false>, scalar_type &> hex_get(scalar_type &t) noexcept { @@ -1747,7 +1749,8 @@ hex_get(scalar_type &t) noexcept } template -inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<16, noskipws, true, true>, scalar_type &> +inline constexpr scalar_manip_t<::fast_io::details::base_scan_mani_flags_cache<16, noskipws, true, true, false>, + scalar_type &> addrvw_get(scalar_type &t) noexcept { return {t}; @@ -1757,7 +1760,7 @@ addrvw_get(scalar_type &t) noexcept template inline constexpr ::fast_io::manipulators::scalar_manip_t< - ::fast_io::details::base_scan_mani_flags_cache<10, false, false, false>, T &> + ::fast_io::details::base_scan_mani_flags_cache<10, false, false, false, false>, T &> scan_alias_define(io_alias_t, T &t) noexcept { return {t}; @@ -1776,7 +1779,7 @@ scan_contiguous_define(io_reserve_type_t t) noexcept { - return details::scan_int_contiguous_define_impl( + return details::scan_int_contiguous_define_impl( begin, end, t.reference); } @@ -1786,7 +1789,7 @@ scan_context_define(io_reserve_type_t t) noexcept { - return details::scan_context_define_parse_impl( + return details::scan_context_define_parse_impl( state, begin, end, t.reference); } @@ -1795,7 +1798,7 @@ inline constexpr parse_code scan_context_eof_define(io_reserve_type_t>, State &state, ::fast_io::manipulators::scalar_manip_t t) noexcept { - return details::scan_context_eof_define_parse_impl( + return details::scan_context_eof_define_parse_impl( state, t.reference); } diff --git a/include/fast_io_core_impl/iso/iso8601.h b/include/fast_io_core_impl/iso/iso8601.h index dba4b004e..bba3d4b22 100644 --- a/include/fast_io_core_impl/iso/iso8601.h +++ b/include/fast_io_core_impl/iso/iso8601.h @@ -867,7 +867,7 @@ struct timestamp_scan_context_buffer_max_size_t private: template static inline constexpr auto size_common{ - ::fast_io::details::print_integer_reserved_size_cache<10, false, ::fast_io::details::my_signed_integral, T>}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, ::fast_io::details::my_signed_integral, false, T>}; public: static inline constexpr auto year_size = size_common<::std::int_least64_t>; @@ -893,7 +893,7 @@ inline constexpr parse_result scn_cnt_define_unix_timestamp_impl(char_type const *begin, char_type const *end, unix_timestamp &t) noexcept { // TODO: whether to accept C-like floatings such as 2. and .2 - auto [itr, ec] = scan_int_contiguous_define_impl<10, false, false, false>(begin, end, t.seconds); + auto [itr, ec] = scan_int_contiguous_define_impl<10, false, false, false, false>(begin, end, t.seconds); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -1073,7 +1073,7 @@ scn_ctx_define_unix_timestamp_impl(timestamp_scan_state_t &state, cha { case scan_timestamp_context_phase::year: { - auto [itr, ec] = scan_context_define_parse_impl<10, false, false, true>(state, begin, end, t.seconds); + auto [itr, ec] = scan_context_define_parse_impl<10, false, false, true, false>(state, begin, end, t.seconds); if (ec != parse_code::ok) { return {itr, ec}; @@ -1432,7 +1432,7 @@ scan_iso8601_context_year_phase(timestamp_scan_state_t &state, char_t if (char_is_digit<10, char_type>(*itr)) [[unlikely]] { state.integer_phase = scan_integral_context_phase::digit; - return scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t); + return scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t); } else { @@ -1478,7 +1478,7 @@ scan_iso8601_context_year_phase(timestamp_scan_state_t &state, char_t if (char_is_digit<10, char_type>(*begin)) [[unlikely]] { state.integer_phase = scan_integral_context_phase::digit; - return scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t); + return scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t); } else { @@ -1497,7 +1497,7 @@ scan_iso8601_context_year_phase(timestamp_scan_state_t &state, char_t } } default: - return scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t); + return scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t); } } diff --git a/include/fast_io_core_impl/socket/addrprt.h b/include/fast_io_core_impl/socket/addrprt.h index 0656fef08..461914180 100644 --- a/include/fast_io_core_impl/socket/addrprt.h +++ b/include/fast_io_core_impl/socket/addrprt.h @@ -398,10 +398,10 @@ inline constexpr ::std::size_t print_reserve_size( using nocvreftype = ::std::remove_cvref_t; constexpr ::std::size_t portsize{ - ::fast_io::details::print_integer_reserved_size_cache<10, false, false, ::std::uint_least16_t>}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, false, false, ::std::uint_least16_t>}; constexpr ::std::size_t v4intsize{ - ::fast_io::details::print_integer_reserved_size_cache<10, false, false, char unsigned>}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, false, false, char unsigned>}; constexpr ::std::size_t v4totalsize{(v4intsize + 1) * 4 - 1}; diff --git a/include/fast_io_core_impl/socket/addrprt2.h b/include/fast_io_core_impl/socket/addrprt2.h index fc2d3bfbc..25436d65d 100644 --- a/include/fast_io_core_impl/socket/addrprt2.h +++ b/include/fast_io_core_impl/socket/addrprt2.h @@ -36,7 +36,7 @@ template <::std::integral char_type> inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t) noexcept { constexpr ::std::size_t char_unsigned_sz{ - ::fast_io::details::print_integer_reserved_size_cache<10, false, false, char unsigned>}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, false, false, char unsigned>}; constexpr ::std::size_t res{char_unsigned_sz * 4 + 3}; return res; } @@ -54,7 +54,7 @@ inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t)}; constexpr ::std::size_t res{ char_unsigned_sz + 1 + - ::fast_io::details::print_integer_reserved_size_cache<10, false, false, ::std::uint_least16_t>}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, false, false, ::std::uint_least16_t>}; return res; } diff --git a/include/fast_io_core_impl/socket/addrscn.h b/include/fast_io_core_impl/socket/addrscn.h index 576e20c1f..70a3e4a43 100644 --- a/include/fast_io_core_impl/socket/addrscn.h +++ b/include/fast_io_core_impl/socket/addrscn.h @@ -32,7 +32,7 @@ struct ip_scan_state_t // overflow/partial state at the length boundary. static inline constexpr auto max_size{ - ::fast_io::details::print_integer_reserved_size_cache<10, false, false, ::std::uint_least16_t> + 1}; + ::fast_io::details::print_integer_reserved_size_cache<10, false, false, false, ::std::uint_least16_t> + 1}; ::fast_io::freestanding::array buffer; scan_integral_context_phase integer_phase{}; ::std::uint_least8_t size{}; @@ -58,7 +58,7 @@ scn_cnt_define_inaddr_impl(char_type const *begin, char_type const *end, posix_i { return {begin, parse_code::invalid}; } - auto [itr0, ec0] = scan_int_contiguous_define_impl<10, true, false, false>(begin, begin + 3, t.address[0]); + auto [itr0, ec0] = scan_int_contiguous_define_impl<10, true, false, false, false>(begin, begin + 3, t.address[0]); if (ec0 != parse_code::ok) [[unlikely]] { return {itr0, ec0}; @@ -76,7 +76,7 @@ scn_cnt_define_inaddr_impl(char_type const *begin, char_type const *end, posix_i return {begin, parse_code::invalid}; } ++begin; - auto [itr1, ec1] = scan_int_contiguous_define_impl<10, true, false, false>(begin, begin + 3, t.address[1]); + auto [itr1, ec1] = scan_int_contiguous_define_impl<10, true, false, false, false>(begin, begin + 3, t.address[1]); if (ec1 != parse_code::ok) [[unlikely]] { return {itr1, ec1}; @@ -98,7 +98,7 @@ scn_cnt_define_inaddr_impl(char_type const *begin, char_type const *end, posix_i { return {begin, parse_code::invalid}; } - auto [itr2, ec2] = scan_int_contiguous_define_impl<10, true, false, false>(begin, begin + 3, t.address[2]); + auto [itr2, ec2] = scan_int_contiguous_define_impl<10, true, false, false, false>(begin, begin + 3, t.address[2]); if (ec2 != parse_code::ok) [[unlikely]] { return {itr2, ec2}; @@ -116,7 +116,7 @@ scn_cnt_define_inaddr_impl(char_type const *begin, char_type const *end, posix_i return {begin, parse_code::invalid}; } ++begin; - auto [itr3, ec3] = scan_int_contiguous_define_impl<10, true, false, false>(begin, end, t.address[3]); + auto [itr3, ec3] = scan_int_contiguous_define_impl<10, true, false, false, false>(begin, end, t.address[3]); if (ec3 != parse_code::ok) [[unlikely]] { return {itr3, ec3}; @@ -145,7 +145,7 @@ scn_ctx_define_inaddr_impl(ipv4_scan_state_t &state, char_type const { return {begin, parse_code::partial}; } - auto [itr, ec] = scan_context_define_parse_impl<10, false, false, false>(state, begin, end, t.address[0]); + auto [itr, ec] = scan_context_define_parse_impl<10, false, false, false, false>(state, begin, end, t.address[0]); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -183,7 +183,7 @@ scn_ctx_define_inaddr_impl(ipv4_scan_state_t &state, char_type const { return {begin, parse_code::partial}; } - auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t.address[1]); + auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t.address[1]); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -221,7 +221,7 @@ scn_ctx_define_inaddr_impl(ipv4_scan_state_t &state, char_type const { return {begin, parse_code::partial}; } - auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t.address[2]); + auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t.address[2]); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -259,7 +259,7 @@ scn_ctx_define_inaddr_impl(ipv4_scan_state_t &state, char_type const { return {begin, parse_code::partial}; } - auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t.address[3]); + auto [itr, ec] = scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t.address[3]); if (ec != parse_code::ok) [[unlikely]] { return {itr, ec}; @@ -291,7 +291,7 @@ inline constexpr parse_result scn_cnt_define_port_impl(char_t return {begin, parse_code::invalid}; } ++begin; - return scan_int_contiguous_define_impl<10, true, false, false>(begin, end, t); + return scan_int_contiguous_define_impl<10, true, false, false, false>(begin, end, t); } template <::std::integral char_type> @@ -318,7 +318,7 @@ inline constexpr parse_result scn_ctx_define_port_impl(ip_por { return {begin, parse_code::partial}; } - return scan_context_define_parse_impl<10, true, false, false>(state, begin, end, t); + return scan_context_define_parse_impl<10, true, false, false, false>(state, begin, end, t); default:; ::fast_io::unreachable(); } diff --git a/include/fast_io_i18n/lc_numbers/integers.h b/include/fast_io_i18n/lc_numbers/integers.h index c912d8c50..9be9c9069 100644 --- a/include/fast_io_i18n/lc_numbers/integers.h +++ b/include/fast_io_i18n/lc_numbers/integers.h @@ -9,7 +9,7 @@ template <::std::integral char_type, manipulators::scalar_flags flags, typename inline constexpr ::std::size_t lc_print_reserve_size_int_cal(basic_lc_all const *__restrict all) noexcept { constexpr ::std::size_t static_size{ - print_integer_reserved_size_cache>}; + print_integer_reserved_size_cache>}; constexpr ::std::size_t static_sizem1{static_size - 1}; return static_size + static_sizem1 * all->numeric.thousands_sep.len; } @@ -334,13 +334,14 @@ inline constexpr char_type *lc_print_reserve_integral_withfull_main_impl(basic_l } template <::std::size_t base, bool showbase = false, bool uppercase_showbase = false, bool showpos = false, - bool uppercase = false, bool full = false, typename int_type, ::std::integral char_type> + bool uppercase = false, bool full = false, bool modern_octal = false, typename int_type, + ::std::integral char_type> inline constexpr char_type *lc_print_reserve_integral_define(basic_lc_all const *__restrict all, char_type *first, int_type t) noexcept { if constexpr (base <= 10 && uppercase) { - return print_reserve_integral_define( + return print_reserve_integral_define( first, t); // prevent duplications } else @@ -384,7 +385,7 @@ inline constexpr char_type *lc_print_reserve_integral_define(basic_lc_all(first); + first = print_reserve_show_base_impl(first); } return lc_print_reserve_integral_withfull_main_impl(all, first, u); } @@ -446,14 +447,14 @@ inline constexpr char_type *print_reserve_define(basic_lc_all const * if constexpr (::std::same_as<::std::remove_cv_t, ::std::byte>) { return details::lc_print_reserve_integral_define( - iter, static_cast(t.reference)); + flags.showpos, flags.uppercase, flags.full, + flags.modern_octal>(all, iter, static_cast(t.reference)); } else { return details::lc_print_reserve_integral_define(all, iter, - t.reference); + flags.showpos, flags.uppercase, flags.full, + flags.modern_octal>(all, iter, t.reference); } } diff --git a/include/fast_io_unit/floating/hexfloat.h b/include/fast_io_unit/floating/hexfloat.h index da454fb8e..240823933 100644 --- a/include/fast_io_unit/floating/hexfloat.h +++ b/include/fast_io_unit/floating/hexfloat.h @@ -50,7 +50,7 @@ inline constexpr char_type *print_rsvhexfloat_define_impl(char_type *iter, flt f } if constexpr (showbase) { - iter = print_reserve_show_base_impl<16, showbase_uppercase>(iter); + iter = print_reserve_show_base_impl<16, showbase_uppercase, false>(iter); } if (!mantissa && !exponent) { @@ -92,8 +92,8 @@ inline constexpr char_type *print_rsvhexfloat_define_impl(char_type *iter, flt f template inline constexpr ::std::size_t print_rsvhexfloat_size_cache{ - print_integer_reserved_size_cache<16, showbase, true, mantissa_type> + 6 + - print_integer_reserved_size_cache<10, true, true, ::std::int_least32_t>}; + print_integer_reserved_size_cache<16, showbase, true, false, mantissa_type> + 6 + + print_integer_reserved_size_cache<10, true, true, false, ::std::int_least32_t>}; } // namespace details diff --git a/include/fast_io_unit/floating/lc_hexfloat.h b/include/fast_io_unit/floating/lc_hexfloat.h index 5ea3742dc..a2032578e 100644 --- a/include/fast_io_unit/floating/lc_hexfloat.h +++ b/include/fast_io_unit/floating/lc_hexfloat.h @@ -31,7 +31,7 @@ inline constexpr char_type *lc_print_rsvhexfloat_define_impl(char_type *iter, fl } if constexpr (showbase) { - iter = print_reserve_show_base_impl<16, showbase_uppercase>(iter); + iter = print_reserve_show_base_impl<16, showbase_uppercase, false>(iter); } if (!mantissa && !exponent) {