8012 Commits

Author SHA1 Message Date
Victor Zverovich
79e48ba915 Move has_format_as to format.h and use it in the tuple formatter
The tuple formatter had a bespoke trait to keep format_as from producing an
ambiguous specialization. detail::has_format_as already answers that question
and std.h applies it the same way, so move it from std.h to format.h where
ranges.h can see it and drop the extra trait.

Check it with conditional_t rather than &&: is_tuple_formattable must not be
instantiated for types with format_as because for self-referential tuple-like
types that recurses back into formatter selection, and && short-circuits
evaluation but not instantiation.
2026-09-20 10:22:10 -07:00
Sachit Madaan
cfb57bfa3a
Fix printf conversion of a zero value with a precision of zero (#4942) 2026-09-19 07:49:15 -07:00
Wu Shuwen
fd0a9b6620
Fix format_as for tuple-like types with ranges.h (#4945) 2026-09-18 15:16:28 -07:00
Victor Zverovich
c4fb197284 Add a missing newline 2026-09-18 14:00:54 -07:00
Yongqiang Tian
c79d5d2141
Limit Clang diagnostic suppressions to fmt declarations (#4948)
format.h and std.h suppress Clang warnings for declarations provided by
fmt, but do not restore the previous diagnostic state. Including either
header therefore also hides the corresponding warning in unrelated
consumer code.

Use fmt's existing Clang diagnostic push and pop macros to limit
-Wweak-vtables to format_error and -Wbit-int-extension to the two
_BitInt aliases.

Signed-off-by: Yongqiang Tian <yqtian668@gmail.com>
2026-09-18 12:37:44 -07:00
Victor Zverovich
b9a6f9be76 Replace the locale #if in chrono.h with a shim template
Both specializations are always parsed while only the selected one is
instantiated. The #else branch it replaces is compiled by no target:
nolocale-test builds src/format.cc, which never reaches chrono.h.
2026-09-18 12:24:28 -07:00
Nebojša Cvetković
e4751cc709
Don't require std::locale in chrono.h when FMT_USE_LOCALE is 0 (#4921)
tm_writer takes a locale_ref and the localized flag instead of a std::locale
reference, and resolves the locale the same way numeric {:L} does: classic
unless localized, otherwise the one passed to the formatting function or the
global one. The facet calls are confined to three shims, so with locale
support disabled nothing pulls in std::locale. get_locale, which existed only
to materialize and own a std::locale, is no longer needed.

The std::tm formatter treated a missing locale argument as the classic locale
rather than the global one, and since #4935 routes {:L} on weekday and month
through it, {:L} without a locale argument ignored the global locale for all
calendar types. It now uses the global locale, as numeric {:L} does. Output
with an explicit locale is unchanged. With FMT_USE_LOCALE=0, {:L} no longer
consults the global locale, matching numeric formatting under that option. An
-Os test program loses all 16 of its std::locale and time_put symbols.
2026-09-16 08:37:57 -07:00
Aurora
5fc5c910c0
Fix unreachable code warning in range formatter (#4932) 2026-09-15 09:39:58 -07:00
Tiago
3a0661d7c0
Don't construct a locale when formatting year_month_day (#4940)
formatter<year_month_day>::format passes true to get_locale, so every default
format constructs a std::locale, and tm_writer then compares it against the
classic locale (is_classic_(loc_ == get_classic_locale())). The only thing
written is on_iso_date(), which is pure arithmetic and reads neither loc_ nor
is_classic_.

It is the odd one out among its siblings: formatter<day> and formatter<year>
pass false; formatter<weekday> and formatter<month> pass their localized()
flag. Only year_month_day hardcodes true, and its parse() never sets localized
in the first place.

With FMT_USE_LOCALE=0 this costs more than a copy: the loc.get<std::locale>()
arm of get_locale is compiled out, so it default-constructs instead, capturing
the current global locale in a build that asked for no locale support.

No output change: chrono_test.year_month_day already sets a non-classic global
locale and expects "2024-01-01".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-13 08:30:16 -07:00
Tiago
e91e92761a
Don't let ADL pick to_string_view (#4938)
* Don't let ADL pick to_string_view

02bf4d1c disabled ADL for to_string_view by qualifying the is_string trait,
and has_to_string_view and char_t are qualified for the same reason. Two call
sites were left behind: value's string constructor and the write() overload
for types with a string view conversion. Both sit inside fmt::detail, where an
unqualified call adds the argument's own namespace to the overload set.

That splits the two halves of one decision. Both call sites are reached only
through has_to_string_view or char_t, which are defined by the qualified
expression, so ADL can never be needed to satisfy them - it can only add
candidates the gate never considered. When the argument's namespace declares a
to_string_view template, the two tie during partial ordering and the call is
ambiguous:

  core.h(2211): error C2668: 'to_string_view': ambiguous call to overloaded
  function
  note: could be 'string_view N::to_string_view<T>(const T&)' [found using
  argument-dependent lookup]
  note: or 'basic_string_view<char> fmt::detail::to_string_view<T,0>(const T&)'

Both are reachable. format("{}", x) stores the argument through value's
constructor; to_string(x) passes it to detail::write unmapped, which lands on
the write() overload, as do FMT_COMPILE named fields and
nested_formatter::write_arg. Reverting either line alone breaks the build of
the test that covers it.

This turned up in Microsoft Office, which declares a constrained
to_string_view template next to its own string types. It only breaks where
those types are distinct classes, so the same code compiles on platforms whose
string types are std aliases - the ADL set is namespace std there and picks up
nothing.

One behaviour change worth noting: a non-template to_string_view in the
argument's namespace used to win outright at these call sites, so a type that
satisfies is_std_string_like via find_first_of and data() but has no size()
formatted through ADL and now fails to compile, because the trait only checks
that the qualified overload is viable, not that its body instantiates. That is
the removed extension point going away rather than a new restriction; ADL
to_string_view stopped being supported in 02bf4d1c.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-12 07:14:49 -07:00
Tiago
e5d13d826f
Make nolocale-test actually disable locale (#4939)
nolocale-test defines FMT_STATIC_THOUSANDS_SEPARATOR, which stopped doing
anything in b90b4bc9 ("Remove FMT_STATIC_THOUSANDS_SEPARATOR in favor of
FMT_USE_LOCALE"). That macro no longer appears anywhere under include/, so
since then the target has compiled src/format.cc with locale support enabled.

It is not a dead target: the pedantic CI jobs build it (linux.yml, macos.yml
both pass -DFMT_PEDANTIC=ON), and it passes. So the configuration looks
covered while nothing actually tests it. #4627 - a locale-off build break -
landed during that window.

Define FMT_USE_LOCALE=0 instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-11 12:39:06 -07:00
Victor Zverovich
14174c826d Add braces for readability 2026-09-11 08:49:10 -07:00
cui fliter
6aa4a5f6f8
Fix debug string formatting for range formatters (#4936)
Signed-off-by: cuishuang <imcusg@gmail.com>
2026-09-11 08:43:46 -07:00
Victor Zverovich
1da57c78d4 Simplify calendar_padding test 2026-09-11 08:31:42 -07:00
IfkumRfnl
2012961e3e
Fix width and alignment for calendar types (#4935) 2026-09-11 08:22:02 -07:00
Victor Zverovich
56fcd0b945 Simplify named_arg_count test 2026-09-11 08:05:34 -07:00
IfkumRfnl
854fc9567a
Fix argument count in dynamic stores with named arguments (#4933) 2026-09-11 08:01:06 -07:00
ilike314272
8dc5d3f69f
Feature: dark mode docs (#4914) 2026-09-09 14:41:50 -07:00
Wu Shuwen
d566765638
Read Doxygen XML independently of the system text encoding (#4925) 2026-09-08 20:45:25 -07:00
Victor Zverovich
44f2c7ae01 Make base.h a compatibility header
Complete the header swap by making core.h canonical and updating code, tests, documentation, and tooling.
2026-09-07 17:11:35 -07:00
Victor Zverovich
e2ef4c01b2 Move the core API back to core.h
base.h was introduced as a temporary migration path; restore the primary header's original name.
2026-09-07 17:05:39 -07:00
Victor Zverovich
5543473f5e Move the compatibility header aside
Free up core.h so base.h can be renamed back with its history preserved.
2026-09-07 17:05:32 -07:00
Victor Zverovich
d3b2fac5c9 Simplify exception_ptr fallback formatting 2026-09-07 15:36:06 -07:00
IfkumRfnl
8a7aea0422
Fix out-of-bounds read in error code format parsing (#4934) 2026-09-07 11:35:29 -07:00
Victor Zverovich
7071103cea Remove incorrect chrono padding claim 2026-09-07 07:59:32 -07:00
Wu Shuwen
7fe204caed
Correct locale support in size optimization docs (#4923) 2026-09-07 07:17:52 -07:00
Jacek Caban
c07e2aa4b1
Disable std::exception_ptr and nested_exception formatters when exceptions are disabled. (#4904)
Fixes building with Clang 20 and older with -fno-exceptions, which treats
try/catch usage as an error.
2026-09-07 07:13:51 -07:00
Ethan Stoner
2d4d8a13c2
Build nolocale-test with /utf-8 on MSVC (#4919)
nolocale-test compiles src/format.cc directly, so it does not pick up the
/utf-8 that CMakeLists.txt adds to the fmt target. On MSVC the static_assert
in base.h then fires: "Unicode support requires compiling with /utf-8".

The target only exists under FMT_PEDANTIC, which the Windows workflow does not
set, so this has not shown up in CI. unicode-test already guards the same flag
the same way.
2026-09-06 13:46:11 -07:00
Victor Zverovich
8be4b46114 Bump mkdocs-material to 9.7.7 2026-09-06 12:26:04 -07:00
Alexander
67ae943b12
Add Quill to the list of notable users (#4931)
One of its unique features is that it serializes the format
string and all format arguments to the thread's SPSQ queue
to minimize processing on hotpath and then deserializes them
on the backend thread which performs formatting using {fmt}
and writing to the log sinks.

Signed-off-by: Alexander Lobakin <alobakin@mailbox.org>
2026-09-06 10:48:02 -07:00
Victor Zverovich
4fcb22bf65 Clarify compile-time benchmark results 2026-09-06 10:25:41 -07:00
Victor Zverovich
d0aae8c15a Refactor range outer formatting 2026-09-06 10:01:08 -07:00
Avionic Harshit
61e3b92396
Support fill, alignment and width in range and tuple formatters (#4910) 2026-09-06 08:47:40 -07:00
Wu Shuwen
0f3c5fd596
Fix the chrono format specification link (#4927) 2026-09-05 15:40:30 -07:00
Victor Zverovich
d90c33606c Apply cmake-format 2026-09-05 08:51:28 -07:00
Dylan Pulver
a389757209
Remove the '0' chrono padding modifier from the docs (#4917)
The '0' modifier was documented in ca8eeb09 (#3976) and the parser case for
it was removed nine days later in 7bd11b5c ("Remove a redundant extension to
reduce divergence from std::format"), which did not update the docs. Since
then the grammar and the modifier table have promised a modifier that
parse_chrono_format rejects with "invalid format", for all 11 of the
presentation types the same section lists as supporting it.

Zero padding remains the default, so the extension really was redundant;
this only aligns the documentation with the code.

Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-09-05 08:33:43 -07:00
Victor Zverovich
de3660a745 Update compile-time benchmark results 2026-09-05 07:20:53 -07:00
Victor Zverovich
6226bc70b8 Enable modules by default with AppleClang 2026-09-04 16:16:19 -07:00
Victor Zverovich
3a110201c9 Use named module file option 2026-09-04 15:49:10 -07:00
Victor Zverovich
40c4f4febb Fix fcntl include in module build 2026-09-04 15:46:08 -07:00
Victor Zverovich
3894ae35ef Fix AppleClang module build 2026-09-04 15:31:24 -07:00
Victor Zverovich
1dd74c0c82 Reorder performance comparison 2026-09-04 12:54:13 -07:00
Victor Zverovich
ba24da597a Simplify performance overview 2026-09-04 12:28:26 -07:00
Victor Zverovich
8bd6079278 Update compile-time benchmark results 2026-09-04 12:13:45 -07:00
Konstantin Goncharuk
fb1a3ef342
docs: add link to a live browser demo (#4916) 2026-09-04 12:01:07 -07:00
Victor Zverovich
ce039d14fe Move migration guidance to documentation 2026-09-04 09:37:28 -07:00
Satyakam Mishra
b4b1657c2a
Fix debug format width calculation (#4902) 2026-09-04 09:17:58 -07:00
Victor Zverovich
ff4a0fdfb9 Streamline README 2026-09-04 09:13:02 -07:00
Victor Zverovich
2e6c5741d2 Move display width table out of function 2026-09-04 08:44:26 -07:00
Victor Zverovich
bc82c408a6 Test dynamic width in nested_formatter 2026-09-02 10:53:56 -07:00