62 Commits

Author SHA1 Message Date
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
Wu Shuwen
7fe204caed
Correct locale support in size optimization docs (#4923) 2026-09-07 07:17:52 -07:00
Wu Shuwen
0f3c5fd596
Fix the chrono format specification link (#4927) 2026-09-05 15:40:30 -07:00
Victor Zverovich
cbb264122a Simplify nested_formatter context handling
Format nested values directly through the stored formatter so dynamic
specifications resolve against the enclosing operation.
2026-09-02 10:14:09 -07:00
Victor Zverovich
9375eb3792 Simplify enum identifier handling and tidy reflection docs
Use std::string_view directly for enumerator identifiers, dropping the
identifier wrapper and inlining count_enumerators. Update the fmt/enum.h
documentation to point at cppreference and drop an inaccurate note. Also
remove the no-longer-needed -Wno-sfinae-incomplete option for format-test.
2026-08-29 15:11:31 -07:00
Avi Kivity
e27cc20bd9
Format enums annotated with fmt::as_identifiers (requires C++26 reflection) (#4885)
* Format enums annotated with fmt::as_identifiers (requires C++26 reflection)

Format an enum as the identifier of the matching enumerator if the enum is
annotated with fmt::as_identifiers:

  enum class [[=fmt::as_identifiers]] color { red, green, blue };
  fmt::format("{}", color::green);  // "green"

Values that don't match any enumerator are represented as their underlying
value in decimal before applying string formatting.

Identifiers are retrieved via C++26 reflection (P2996) and the annotation
via P3394. FMT_USE_REFLECTION is autodetected and can be overridden by the
user; without reflection the header is empty.

The header is also part of the fmt module, but, unlike with headers, whether
it provides anything is decided when the module is compiled, so the module
build detects reflection and enables it if the configured standard allows.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Look up enum identifiers by index when the values are dense

The formatter for enums annotated with fmt::as_identifiers did a linear
search over all enumerators. Build a table indexed by the distance from
the smallest enumerator value instead, with empty string views in the
holes, which reduces the lookup to a bounds check and one load.

The table is only used if at least 70% of its elements are identifiers,
limiting its size to 10/7 of the number of enumerators. Sparser enums
keep using the linear search. Distances are computed in uint64_t so that
enums with negative values and values spanning the whole range of the
underlying type are handled without overflow.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Suppress -Wsfinae-incomplete in format-test on GCC 16

GCC 16 warns when a type is completed after it failed to be complete in a
SFINAE context. format-test does this deliberately to check that formatting
of incomplete types works, so the warning is a false positive there and
breaks the build with -Werror.

* Test GCC 16 on CI

GCC 16 is the first compiler with C++26 reflection support, which is needed
by fmt/enum.h, so add a job that builds with it in C++26 mode. It comes from
the ubuntu-toolchain-r/test PPA since Ubuntu 24.04 only ships GCC 14.

Also report when reflection is not detected to make it visible that
enum-test was skipped.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 09:31:28 -07:00
rimathia
17500e457b
doc extension concerning format_as and general implementations (#4857) 2026-07-29 09:43:31 -07:00
Victor Zverovich
0f133953fb Tweak docs 2026-03-03 08:20:51 -08:00
Mathew Benson
4e1b170b44
Add Separate CMake Target for C++20 Modules (#4685)
* Add Separate CMake Target for C++20 Modules

In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and
`fmt::fmt_c` targets, I propose the addition of a new target
`fmt::fmt-module` which will be for the compilation of the FMT_MODULE
library option.

The new target will have the properties requried for Compiling,
Installing and using the C++20 functionality in CMake

The `add_module_library` function is marked as deprecated as its
functionality is superseded.

Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the
versions for Ninja and MSVC according the CMAKE Documents and setting
the FMT_MODULE flag based on this

* Add Separate CMake Target for C++20 Modules

In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and
`fmt::fmt_c` targets, I propose the addition of a new target
`fmt::fmt-module` which will be for the compilation of the FMT_MODULE
library option.

The new target will have the properties requried for Compiling,
Installing and using the C++20 functionality in CMake

Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the
versions for Ninja and MSVC according the CMAKE Documents and setting
the FMT_MODULE flag based on this

Fixed the test/CMakeLists.txt file which used the FMT_MODULE flag to
separate the module and non-module library testing, in particular
disableing the module version.

The module testing still needs to be fixed, but the expected behavior of
testing the non-modular version is working.

---------

Co-authored-by: Mathew Benson <mathew@benson.co.ke>
Co-authored-by: ClausKlein <claus.klein@arcormail.de>
2026-03-02 09:11:31 -08:00
ssszcmawo
28b082cc2b
Cleanup documentation (#4667)
* Cleanup documentation

* Fix comment typo in fmt::formatter struct

* Fix formatting and grammar in api.md

Corrected formatting and grammar in the API documentation.
2026-02-04 18:47:47 -08:00
Victor Zverovich
48967e1b6f Cleanup named args 2026-02-02 11:08:01 -08:00
user202729
2e819a11f2
Some documentation improvements (#4631) 2025-12-17 06:53:01 -08:00
bigmoonbit
2727215c11
chore: minor improvement for docs (#4616)
Signed-off-by: bigmoonbit <bigmoonbit@outlook.com>
2025-11-28 12:55:25 -08:00
Victor Zverovich
a0571f3f59 Document output_file 2025-11-03 10:11:31 -10:00
Victor Zverovich
beefc1c14f Tweak wording 2025-10-12 10:54:28 -07:00
Victor Zverovich
81fe170849 Update docs 2025-10-12 10:42:12 -07:00
Victor Zverovich
491dc16a6d Cleanup docs 2025-10-12 10:33:05 -07:00
Victor Zverovich
41326207c7 Cleanup docs 2025-10-12 10:20:16 -07:00
Victor Zverovich
c4f70ab69e Cleanup docs 2025-10-12 09:34:46 -07:00
Victor Zverovich
5e214f0c43 Cleanup docs 2025-10-12 09:24:58 -07:00
teruyamato0731
4801f54e59
docs: Add compile-time options to API documentation (#4551) 2025-09-30 14:03:11 -07:00
Victor Zverovich
bfdef8b15d Remove deprecated functions 2025-09-13 09:25:53 -07:00
Victor Zverovich
20e0d6d8dd Update docs 2025-09-01 10:15:54 -07:00
Victor Zverovich
8ba99c0f05 Update docs 2025-09-01 10:04:54 -07:00
Victor Zverovich
656228fbee Update docs 2025-09-01 09:50:45 -07:00
Victor Zverovich
a75e8af487 Update docs 2025-08-31 10:51:29 -07:00
Victor Zverovich
489fd7ca4b Simplify locale handling 2025-08-31 09:33:43 -07:00
Victor Zverovich
a77efa4b4a Move is_*char to detail 2025-08-24 09:16:18 -07:00
Victor Zverovich
3ba3c390fb Clarify that formatting of pointers is disallowed 2025-05-17 10:16:58 -07:00
Victor Zverovich
102752ad45 Update docs 2025-05-11 09:13:12 -07:00
Victor Zverovich
eb9a95d426 Clarify that formatting of pointers is disallowed 2025-05-05 10:55:59 -07:00
Victor Zverovich
9f6c12c3dc Remove deprecated localtime from docs 2025-04-25 11:58:58 -07:00
krzysztofkortas
db405954cd
Remove fmt/core.h from docs (#4421) 2025-04-20 07:40:18 -07:00
Victor Chernyakin
b776cf66fc
Optimize text_style using bit packing (#4363) 2025-03-01 11:18:19 -08:00
Victor Zverovich
373855c1b0 Clarify difference in FP representation 2025-01-26 13:49:54 -08:00
Victor Zverovich
21aa0956d4 Restore ABI compatibility 2025-01-10 17:36:09 -08:00
Victor Zverovich
853df39d0a Mention compile-time formatting 2024-12-26 09:48:10 -08:00
Victor Zverovich
da24fac101 Document fstring 2024-12-26 09:19:31 -08:00
Victor Zverovich
d8a79eafdc Document formatting of bit-fields and fields of packed structs 2024-12-21 11:06:11 -08:00
Victor Zverovich
e9eaa27e5a Add std::exception to the docs 2024-10-20 09:42:29 -07:00
Victor Zverovich
02537548f3 Cleanup an example 2024-10-04 17:15:07 -07:00
Victor Zverovich
ff92223549 Simplify locale handling 2024-09-22 10:21:19 -07:00
Victor Zverovich
92cdbbae06
Update api.md 2024-07-10 15:50:10 -07:00
Victor Zverovich
28673d9699
Update api.md 2024-06-11 12:27:12 -07:00
Victor Zverovich
a1337aa8aa Merge literal-based API doc into the parent section 2024-06-09 18:16:56 -07:00
Victor Zverovich
d1cab6a9ae Drop parentheses 2024-06-09 10:58:02 -07:00
LoveSy
fe741daaab
Mention namespace fmt::literals in the document (#4002) 2024-06-08 14:31:51 -07:00
Victor Zverovich
0a555818d7 Usage -> Get Started 2024-06-05 07:59:06 -07:00
Victor Zverovich
966a1b3d44 Update docs 2024-06-05 07:19:14 -07:00
Victor Zverovich
2c84fa9ac9 Update docs 2024-06-05 06:19:40 -07:00