10.0.0
-
Replaced Grisu with a new floating-point formatting algorithm for given precision (#3262, #2750, #3269, #3276). The new algorithm is based on Dragonbox already used for the shortest representation and gives substantial performance improvement:
-
Red: new algorithm
-
Green: new algorithm with
FMT_USE_FULL_CACHE_DRAGONBOX
defined to 1 -
Blue: old algorithm
Thanks @jk-jeon (Junekey Jeon).
-
-
Replaced
snprintf
-based hex float formatter with an internal implementation (#3179, #3203). This removes the last usage ofs(n)printf
in {fmt}. Thanks @phprus (Vladislav Shchapov). -
Fixed alignment of floating-point numbers with localization (#3263, #3272). Thanks @ShawnZhong (Shawn Zhong).
-
Made handling of
#
consistent withstd::format
. -
Improved C++20 module support (#3134, #3254, #3386, #3387, #3388, #3392, #3397, #3399, #3400). Thanks @laitingsheng (Tinson Lai), @Orvid (Orvid King), @DanielaE (Daniela Engert). Switched to the modules CMake library which allows building {fmt} as a C++20 module with clang:
CXX=clang++ cmake -DFMT_MODULE=ON . make
-
Made
format_as
work with any user-defined type and not just enums. For example (godbolt):#include <fmt/format.h> struct floaty_mc_floatface { double value; }; auto format_as(floaty_mc_floatface f) { return f.value; } int main() { fmt::print("{:8}\n", floaty_mc_floatface{0.42}); // prints " 0.42" }
-
Removed deprecated implicit conversions for enums and conversions to primitive types for compatibility with
std::format
and to prevent potential ODR violations. Useformat_as
instead. -
Added support for fill, align and width to the time point formatter (#3237, #3260, #3275). For example (godbolt):
#include <fmt/chrono.h> int main() { // prints " 2023" fmt::print("{:>8%Y}\n", std::chrono::system_clock::now()); }
Thanks @ShawnZhong (Shawn Zhong).
-
Implemented formatting of subseconds (#2207, #3117, #3115, #3143, #3144, #3349). For example (godbolt):
#include <fmt/chrono.h> int main() { // prints 01.234567 fmt::print("{:%S}\n", std::chrono::microseconds(1234567)); }
Thanks @patrickroocks (Patrick Roocks) @phprus (Vladislav Shchapov), @BRevzin (Barry Revzin).
-
Added precision support to
%S
(#3148). Thanks @SappyJoy (Stepan Ponomaryov) -
Added support for
std::utc_time
(#3098, #3110). Thanks @patrickroocks (Patrick Roocks). -
Switched formatting of
std::chrono::system_clock
from local time to UTC for compatibility with the standard (#3199, #3230). Thanks @ned14 (Niall Douglas). -
Added support for
%Ez
and%Oz
to chrono formatters. (#3220, #3222). Thanks @phprus (Vladislav Shchapov). -
Improved validation of format specifiers for
std::chrono::duration
(#3219, #3232). Thanks @ShawnZhong (Shawn Zhong). -
Fixed formatting of time points before the epoch (#3117, #3261). For example (godbolt):
#include <fmt/chrono.h> int main() { auto t = std::chrono::system_clock::from_time_t(0) - std::chrono::milliseconds(250); fmt::print("{:%S}\n", t); // prints 59.750000000 }
Thanks @ShawnZhong (Shawn Zhong).
-
Experimental: implemented glibc extension for padding seconds, minutes and hours (#2959, #3271). Thanks @ShawnZhong (Shawn Zhong).
-
Added a formatter for
std::exception
(#2977, #3012, #3062, #3076, #3119). For example (godbolt):#include <fmt/std.h> #include <vector> int main() { try { std::vector<bool>().at(0); } catch(const std::exception& e) { fmt::print("{}", e); } }
prints:
vector<bool>::_M_range_check: __n (which is 0) >= this->size() (which is 0)
on libstdc++. Thanks @zach2good (Zach Toogood) and @phprus (Vladislav Shchapov).
-
Moved
std::error_code
formatter fromfmt/os.h
tofmt/std.h
. (#3125). Thanks @phprus (Vladislav Shchapov). -
Added formatters for standard container adapters:
std::priority_queue
,std::queue
andstd::stack
(#3215, #3279). For example (godbolt):#include <fmt/ranges.h> #include <stack> #include <vector> int main() { auto s = std::stack<bool, std::vector<bool>>(); for (auto b: {true, false, true}) s.push(b); fmt::print("{}\n", s); // prints [true, false, true] }
Thanks @ShawnZhong (Shawn Zhong).
-
Added a formatter for
std::optional
tofmt/std.h
. Thanks @tom-huntington. -
Fixed formatting of valueless by exception variants (#3347). Thanks @TheOmegaCarrot.
-
Made
fmt::ptr
acceptunique_ptr
with a custom deleter (#3177). Thanks @hmbj (Hans-Martin B. Jensen). -
Fixed formatting of noncopyable ranges and nested ranges of chars (#3158 #3286, #3290). Thanks @BRevzin (Barry Revzin).
-
Fixed issues with formatting of paths and ranges of paths (#3319, #3321 #3322). Thanks @phprus (Vladislav Shchapov).
-
Improved handling of invalid Unicode in paths.
-
Enabled compile-time checks on Apple clang 14 and later (#3331). Thanks @cloyce (Cloyce D. Spradling).
-
Improved compile-time checks of named arguments (#3105, #3214). Thanks @rbrich (Radek Brich).
-
Fixed formatting when both alignment and
0
are given (#3236, #3248). Thanks @ShawnZhong (Shawn Zhong). -
Improved Unicode support in the experimental file API on Windows (#3234, #3293). Thanks @Fros1er (Froster).
-
Unified UTF transcoding (#3416). Thanks @phprus (Vladislav Shchapov).
-
Added support for UTF-8 digit separators via an experimental locale facet (#1861). For example (godbolt):
auto loc = std::locale( std::locale(), new fmt::format_facet<std::locale>("β")); auto s = fmt::format(loc, "{:L}", 1000);
where
β
is U+2019 used as a digit separator in the de_CH locale. -
Added an overload of
formatted_size
that takes a locale (#3084, #3087). Thanks @gerboengels. -
Removed the deprecated
FMT_DEPRECATED_OSTREAM
. -
Fixed a UB when using a null
std::string_view
withfmt::to_string
or format string compilation (#3241, #3244). Thanks @phprus (Vladislav Shchapov). -
Added
starts_with
to the fallbackstring_view
implementation (#3080). Thanks @phprus (Vladislav Shchapov). -
Added
fmt::basic_format_string::get()
for compatibility withbasic_format_string
(#3111). Thanks @huangqinjin. -
Added
println
for compatibility with C++23 (#3267). Thanks @ShawnZhong (Shawn Zhong). -
Renamed the
FMT_EXPORT
macro for shared library usage toFMT_LIB_EXPORT
. -
Improved documentation (#3108, #3169, #3243). #3404). Thanks @Cleroth and @Vertexwahn.
-
Improved build configuration and tests (#3118, #3120, #3188, #3189, #3198, #3205, #3207, #3210, #3240, #3256, #3264, #3299, #3302, #3312, #3317, #3328, #3333, #3369, #3373, #3395, #3406, #3411). Thanks @dimztimz (Dimitrij Mijoski), @phprus (Vladislav Shchapov), @DavidKorczynski, @ChrisThrasher (Chris Thrasher), @FrancoisCarouge (François Carouge), @kennyweiss (Kenny Weiss), @luzpaz, @codeinred (Alecto Irene Perez), @Mixaill (Mikhail Paulyshka), @joycebrum (Joyce), @kevinhwang (Kevin Hwang), @Vertexwahn.
-
Fixed a regression in handling empty format specifiers after a colon (
{:}
) (#3086). Thanks @oxidase (Michael Krasnyk). -
Worked around a broken implementation of
std::is_constant_evaluated
in some versions of libstdc++ on clang (#3247, #3281). Thanks @phprus (Vladislav Shchapov). -
Fixed formatting of volatile variables (#3068).
-
Fixed various warnings and compilation issues (#3057, #3066, #3072, #3082, #3091, #3092, #3093, #3095, #3096, #3097, #3128, #3129, #3137, #3139, #3140, #3142, #3149, #3150, #3154, #3163, #3178, #3184, #3196, #3204, #3206, #3208, #3213, #3216, #3224, #3226, #3228, #3229, #3259, #3274, #3287, #3288, #3292, #3295, #3296, #3298, #3325, #3326, #3334, #3342, #3343, #3351, #3352, #3362, #3365, #3366, #3374, #3377, #3378, #3381, #3398, #3413, #3415). Thanks @phprus (Vladislav Shchapov), @gsjaardema (Greg Sjaardema), @NewbieOrange, @EngineLessCC (VivyaCC), @asmaloney (Andy Maloney), @HazardyKnusperkeks (BjΓΆrn SchΓ€pers), @sergiud (Sergiu Deitsch), @Youw (Ihor Dutchak), @thesmurph, @czudziakm (Maksymilian Czudziak), @Roman-Koshelev, @chronoxor (Ivan Shynkarenka), @ShawnZhong (Shawn Zhong), @russelltg (Russell Greene), @glebm (Gleb Mazovetskiy), @tmartin-gh, @Zhaojun-Liu (June Liu), @louiswins (Louis Wilson), @mogemimi.
Pull Requests
- Added workarounds for compilers with EDG frontend (LCC and Nvidia) by @phprus in #3057
- Fix compilation error with gcc-7.2.0 by @gsjaardema in #3066
- Add formatter for std::exception by @zach2good in #3062
- Simplify is_variant_like_ check, fix compile error before GCC 11 by @NewbieOrange in #3072
- Add starts_with to fmt::basic_string_view. by @phprus in #3080
- Fix intellisense on Windows by @enginelesscc in #3082
- Add locale overload for formatted_size (#3084) by @gerboengels in #3087
- Add class name output to formatter for std::exception by @phprus in #3076
- Fix compilation with FMT_ENFORCE_COMPILE_STRING and FMT_WERROR by @asmaloney in #3091
- Fix build error on GCC-9 by @phprus in #3093
- fix gcc <= 7.1 compile errors by @sergiud in #3097
- Fix warnings by @HazardyKnusperkeks in #3095
- Add basic_format_string::get() by @huangqinjin in #3111
- Update CI to Ubuntu 20.04 and to newer versions of actions by @dimztimz in #3118
- Support formatting of time_point with utc_clock by @patrickroocks in #3110
- Set CMAKE_RUNTIME_OUTPUT_DIRECTORY relative to CMAKE_CURRENT_BINARY_DIR by @phprus in #3120
- Normalization of stdlib inline namespace names by @phprus in #3119
- Move formatterstd::error_code from fmt/os.h to fmt/std.h by @phprus in #3125
- Fix broken condition by @phprus in #3129
- Fix options for C++20 experimental module in CMake by @laitingsheng in #3134
- Avoid using
uint
as a type name by @Youw in #3137 - Support formatting of subseconds by @patrickroocks in #3115
- Remove duplicate template parameter. by @phprus in #3142
- Fix overflow error by @phprus in #3143
- Remove duplicate implementation by @phprus in #3144
- Mention MariaDB amongst the projects that use fmt by @federico-razzoli in #3145
- Fix warning: conditional expression is constant. by @phprus in #3150
- Add locale getter in tm_writer by @SappyJoy in #3147
- fmt::ostream - aggregate buffer instead of inheriting it by @Youw in #3139
- Fixing formatting of range of range of char. by @brevzin in #3158
- Add precision modifier for seconds in chrono format by @SappyJoy in #3148
- Replace format with FMT_STRING. by @phprus in #3162
- Format unique_ptr with custom deleter by @hmbj in #3177
- This skips the scan-test if strptime isn't defined. by @thesmurph in #3184
- Improve CI by @phprus in #3188
- Fix warnings for compilers with EDG frontend by @phprus in #3196
- Replacing snprintf-based hex float formatter with internal implementation by @phprus in #3179
- CI linux: add CIFuzz Github action by @DavidKorczynski in #3198
- Rename leading_v -> leading_xdigit by @phprus in #3203
- Use
target_compile_features
to specify C++ standard requirement by @ChrisThrasher in #3205 - Skip only strptime dependent test in scan-test by @phprus in #3206
- Remove workaround for GTest bug by @phprus in #3207
- Bump tested CMake version to 3.25 by @phprus in #3210
- Add countl_zero function by @phprus in #3216
- fix #3105 - Compile-time error when mixing named argument with automatic indexing by @rbrich in #3214
- Implement %Ez, %Oz for chrono formatter by @phprus in #3222
- Fix for issue #3228 by @phprus in #3229
- Check chrono spec starts with % by @ShawnZhong in #3232
- small typo in syntax.rst by @Cleroth in #3243
- Fix for issue #3241 by @phprus in #3244
- Ignore 0 character when align is present by @ShawnZhong in #3248
- Remove empty semicolon by @ShawnZhong in #3249
- Improve timezone tests by @phprus in #3240
- Fix build with MSVC C++20 modules by @Orvid in #3254
- Support fill, align & width for time point by @ShawnZhong in #3260
- Fix standard default installation target presence by @FrancoisCarouge in #3264
- Fix negative subsec for time_point by @ShawnZhong in #3261
- Bugfix for fmt::printf on Power9 architecture with the XL compiler by @kennyweiss in #3256
- Implement a new formatting algorithm for small given precision by @jk-jeon in #3269
- Fix localized format for float-point numbers by @ShawnZhong in #3272
- Fix spec "{:}" for time point by @ShawnZhong in #3275
- Refactor countl_zero fallback by @jk-jeon in #3276
- Workaround for incompatibility between libstdc++ consteval-based std::is_constant_evaluated() implementation and clang-14 by @phprus in #3281
- Implement
println
by @ShawnZhong in #3267 - Visual Studio 2022: fmt/format-inl.h(1145,60): warning C4310: cast truncates constant value #3287 by @chronoxor in #3288
- Allowing formatting non-copyable ranges. by @brevzin in #3290
- Fix errors setting of FMT_USE_FLOAT128 by @Roman-Koshelev in #3259
- Implement glibc ext for sec, min, and hour by @ShawnZhong in #3271
- Add formatters for container adapters by @ShawnZhong in #3279
- Fix OpenBSD build error by @ShawnZhong in #3295
- Add ubuntu mirrors by @phprus in #3302
- change sopen_s to wsopen_s (#3234) by @Fros1er in #3293
- Fix various typos by @luzpaz in #3312
- Add Optional Support by @tom-huntington in #3303
- Fix for issue #3325 by @phprus in #3326
- chore: set permission to cifuzz.yml by @joycebrum in #3328
- Enable consteval for Xcode 14 and later by @cloyce in #3331
- Fix for issue #3319. by @phprus in #3321
- Cleanup dead variable by @ShawnZhong in #3338
write_floating_seconds
: Fall back to::round
by @glebm in #3343- Fix CUDA nvcc warning by @tmartin-gh in #3352
- fix case of variant which is valueless by exception by @TheOmegaCarrot in #3347
- %T is %H:%M:%S by @brevzin in #3349
- Force use a signed char (On ARM char is unsigned by default) by @phprus in #3362
- Workaround a double-double hexfloat format by @phprus in #3366
- fix compilation for MS-DOS by @Mixaill in #3369
- ranges: Fix extra semi by @HazardyKnusperkeks in #3374
- Fix error C2668 on msvc by @Zhaojun-Liu in #3378
- fix and improve module by @DanielaE in #3386
- Feature/remove obsolete workarounds by @DanielaE in #3388
- Update tests to use recommended MOCK_METHOD by @kevinhwang in #3395
- Fix MSVC C4365 warning (signed/unsigned mismatch) on 32-bit Windows by @louiswins in #3398
- names declared to be exported at the point of introduction into a nam⦠by @DanielaE in #3392
- Feature/attach to gmf by @DanielaE in #3387
- Name
vfprintf
clashes with the identically named declaration in 'st⦠by @DanielaE in #3400 - Remove myself from maintainer list by @foonathan in #3402
- Fix spelling by @Vertexwahn in #3404
- Bazel support by @Vertexwahn in #3406
- Remove .bazelrc mention from Bazel related readme by @Vertexwahn in #3411
- towards better module testing by @DanielaE in #3397
- Add
FMT_STRING
forformat_to()
call with clang-cl by @mogemimi in #3413 - modules missing pieces by @DanielaE in #3399
- Unification utf16/utf32 to utf8 conversion by @phprus in #3416
New Contributors
- @zach2good made their first contribution in #3062
- @NewbieOrange made their first contribution in #3072
- @enginelesscc made their first contribution in #3082
- @gerboengels made their first contribution in #3087
- @asmaloney made their first contribution in #3091
- @huangqinjin made their first contribution in #3111
- @patrickroocks made their first contribution in #3110
- @laitingsheng made their first contribution in #3134
- @Youw made their first contribution in #3137
- @federico-razzoli made their first contribution in #3145
- @SappyJoy made their first contribution in #3147
- @hmbj made their first contribution in #3177
- @thesmurph made their first contribution in #3184
- @DavidKorczynski made their first contribution in #3198
- @ChrisThrasher made their first contribution in #3205
- @rbrich made their first contribution in #3214
- @ShawnZhong made their first contribution in #3232
- @Cleroth made their first contribution in #3243
- @Orvid made their first contribution in #3254
- @FrancoisCarouge made their first contribution in #3264
- @kennyweiss made their first contribution in #3256
- @Fros1er made their first contribution in #3293
- @luzpaz made their first contribution in #3312
- @tom-huntington made their first contribution in #3303
- @joycebrum made their first contribution in #3328
- @cloyce made their first contribution in #3331
- @glebm made their first contribution in #3343
- @tmartin-gh made their first contribution in #3352
- @TheOmegaCarrot made their first contribution in #3347
- @Mixaill made their first contribution in #3369
- @Zhaojun-Liu made their first contribution in #3378
- @kevinhwang made their first contribution in #3395
- @louiswins made their first contribution in #3398
- @mogemimi made their first contribution in #3413
Full Changelog: 9.1.0...10.0.0