A named argument that arrives const-qualified was not recognized by
is_named_arg, silently dropping its name. This happens both when a
named argument is passed through an intermediate function returning
const T& (https://github.com/fmtlib/fmt/issues/4866) and in fmt's own
compiled format path, which passes arguments as const T&.
Make is_named_arg and is_static_named_arg see through top-level const so
the name is preserved instead of dropped.
fmt::detail::display_width_of() only treated East Asian Wide/Fullwidth
code points and two hand-picked emoji ranges as two columns wide, so
emoji outside those ranges (e.g. the Dingbats block: cross mark U+274C,
white heavy check mark U+2705) were measured as one column even though
most terminals render them double-width. This produced visibly
inconsistent padding under {:^N} compared to CJK text (fixes#4851).
Replaced the ad hoc boolean expression with a sorted table of ranges
(East Asian Wide/Fullwidth plus the full Emoji_Presentation set from
Unicode's emoji-data.txt) looked up via binary search, and added
regression tests covering the original report plus edge cases:
multiple emoji, mixed emoji/CJK/ASCII content, precision truncation,
alignment/fill variants, newly covered emoji ranges, and regional
indicator (flag) pairs.
Make basic_ostream_formatter, ostream_formatter and streamed() accessible
to module users via FMT_BEGIN_EXPORT/FMT_BEGIN_EXPORT. Drop now unneeded
FMT_EXPORT for print() and println().
count_digits and do_format_decimal divided the full 128-bit value by a
constant in a loop. Compilers do not strength-reduce 128-bit division, so
each iteration became a slow __udivti3 library call (~27 per number).
Reduce the value to 64-bit chunks by dividing by 10^19 (at most twice) and
reuse the fast 64-bit paths, giving a ~5x speedup on full-range values.
Formatting an integer with ':c' used the magnitude (abs_value) and never
range-checked, so negatives were mangled and out-of-range values silently
truncated. Copy the value as a character and report an error when it is out
of range, treating all character types as unsigned for portability.
The appender and generic-iterator overloads only differed in whether the
integer formatting code was inlined. Merge them into a single overload and
select write_int_noinline vs inline write_int via if constexpr, keeping the
same codegen (out of line for appenders, inlined for compiled formatting)
with no size regression.
Detect when a std::exception also derives from std::nested_exception
(e.g. via std::throw_with_nested) and unwind the whole chain, joining
each level with ": ". The type-name flag ({:t}) is honored at every
level, and the std::exception_ptr formatter inherits this behavior.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use num_bits<UInt>() == 32 instead of sizeof(UInt) == 4 in
do_format_decimal. The magic-number two-digit algorithm requires
exactly 32 value bits, so this is more precise on platforms where
CHAR_BIT != 8 and is consistent with existing num_bits<T>() usage.
Revert the explicit-else workaround from #4822 and instead disable the
"unreachable code" warning for all of base.h. Add an FMT_PRAGMA_MSVC
helper (mirroring FMT_PRAGMA_GCC/CLANG) and wrap the header in a single
warning(push)/disable:4702/pop pair, keeping the original control flow.
if FMT_CONSTEXPR is resolved to constexpr MSC warns about dead code
after 'return' instruction. Explicitly using 'else' in these cases
avoids the warning.
Prevent false positives when the container itself does not have `operator[](size_t)`, but the target type of one of the non-explicit user-defined conversion functions does.
Just a tiny bugfix I spotted: The `f(un)lockfile` wrappers in
`format-inl.h` that wrap Windows's `_(un)lock_file` methods are
defined with a trailing return type derived by using decltype on a
hypothetical call to the underlying functions.
The wrappers don't contain a `return` in their bodies, however, so if
the return type of the underlying functions were to ever change from
`void`, there would be a compile error. This just adds `return` to each.