Releases: fmtlib/fmt
12.1.0
-
Optimized
buffer::append, resulting in up to ~16% improvement on spdlog benchmarks (#4541). Thanks @fyrsta7. -
Worked around an ABI incompatibility in
std::locale_refbetween clang and gcc (#4573). -
Made
std::variantandstd::expectedformatters work withformat_as(#4574, #4575). Thanks @phprus. -
Made
fmt::join<string_view>work with C++ modules (#4379, #4577). Thanks @Arghnews. -
Exported
fmt::is_compiled_stringandoperator""_cffrom the module (#4544). Thanks @CrackedMatter. -
Fixed a compatibility issue with C++ modules in clang (#4548). Thanks @tsarn.
-
Added support for cv-qualified types to the
std::optionalformatter (#4561, #4562). Thanks @OleksandrKvl. -
Added demangling support (used in exception and
std::type_infoformatters) for libc++ and clang-cl (#4542, #4560, #4568, #4571). Thanks @FatihBAKIR and @rohitsutreja. -
Switched to global
malloc/freeto enable allocator customization (#4569, #4570). Thanks @rohitsutreja. -
Made the
FMT_USE_CONSTEVALmacro configurable by users (#4546). Thanks @SnapperTT. -
Fixed compilation with locales disabled in the header-only mode (#4550).
-
Fixed compilation with clang 21 and
-std=c++20(#4552). -
Fixed a dynamic linking issue with clang-cl (#4576, #4584). Thanks @FatihBAKIR.
-
Fixed a warning suppression leakage on gcc (#4588). Thanks @ZedThree.
-
Made more internal color APIs
constexpr(#4581). Thanks @ishani. -
Fixed compatibility with clang as a host compiler for NVCC (#4564). Thanks @valgur.
-
Fixed various warnings and lint issues (#4565, #4572, #4557). Thanks @LiangHuDream and @teruyamato0731.
-
Improved documentation (#4549, #4551, #4566, #4567, #4578,). Thanks @teruyamato0731, @petersteneteg and @zimmerman-dev.
12.0.0
-
Optimized the default floating point formatting (#3675, #4516). In particular, formatting a
doublewith format string compilation into a stack allocated buffer is more than 60% faster in version 12.0 compared to 11.2 according to dtoa-benchmark:Function Time (ns) Speedup fmt11 34.471 1.00x fmt12 21.000 1.64x
-
Added
constexprsupport tofmt::format. For example:#include <fmt/compile.h> using namespace fmt::literals; std::string s = fmt::format(""_cf, 42);
now works at compile time provided that
std::stringsupportsconstexpr(#3403, #4456). Thanks @msvetkin. -
Added
FMT_STATIC_FORMATthat allows formatting into a string of the exact required size at compile time.For example:
#include <fmt/compile.h> constexpr auto s = FMT_STATIC_FORMAT("{}", 42);
compiles to just
__ZL1s: .asciiz "42"
It can be accessed as a C string with
s.c_str()or as a string view withs.str(). -
Improved C++20 module support (#4451, #4459, #4476, #4488, #4491, #4495). Thanks @arBmind, @tkhyn, @Mishura4, @anonymouspc and @autoantwort.
-
Switched to using estimated display width in precision. For example:
fmt::print("|{:.4}|\n|1234|\n", "π±π±π±");
prints
because
π±has an estimated width of 2 (#4272, #4443, #4475). Thanks @nikhilreddydev and @localspook. -
Fix interaction between debug presentation, precision, and width for strings (#4478). Thanks @localspook.
-
Implemented allocator propagation on
basic_memory_buffermove (#4487, #4490). Thanks @toprakmurat. -
Fixed an ambiguity between
std::reference_wrapper<T>andformat_asformatters (#4424, #4434). Thanks @jeremy-rifkin. -
Removed the following deprecated APIs:
has_formatter: useis_formattableinstead, -basic_format_args::parse_context_type,basic_format_args::formatter_typeand similar aliases in context types, - wide stream overload offmt::printf, - wide stream overloads offmt::printthat take text styles, -is_*chartraits, -fmt::localtime.
-
Deprecated wide overloads of
fmt::fprintfandfmt::sprintf. -
Improved diagnostics for the incorrect usage of
fmt::ptr(#4453). Thanks @TobiSchluter. -
Made handling of ANSI escape sequences more efficient (#4511, #4528). Thanks @localspook and @Anas-Hamdane.
-
Fixed a buffer overflow on all emphasis flags set (#4498). Thanks @dominicpoeschko.
-
Fixed an integer overflow for precision close to the max
intvalue. -
Fixed compatibility with WASI (#4496, #4497). Thanks @whitequark.
-
Fixed
back_insert_iteratordetection, preventing a fallback on slower path that handles arbitrary iterators (#4454). -
Fixed handling of invalid glibc
FILEbuffers (#4469). -
Added
wchar_tsupport to thestd::byteformatter (#4479, #4480). Thanks @phprus. -
Changed component prefix from
fmt-tofmt_for compatibility with NSIS/CPack on Windows, e.g.fmt-docchanged tofmt_doc(#4441, #4442). Thanks @n-stein. -
Added the
FMT_CUSTOM_ASSERT_FAILmacro to simplify providing a customfmt::assert_failimplementation (#4505). Thanks @HazardyKnusperkeks. -
Switched to
FMT_THROWon reporting format errors so that it can be overriden by users when exceptions are disabled (#4521). Thanks @HazardyKnusperkeks. -
Improved master project detection and disabled install targets when using {fmt} as a subproject by default (#4536). Thanks @crueter.
-
Made various code improvements (#4445, #4448, #4473, #4522). Thanks @localspook, @tchaikov and @way4sahil.
-
Added Conan instructions to the docs (#4537). Thanks @uilianries.
-
Removed Bazel files to avoid issues with downstream packaging (#4530). Thanks @mering.
-
Added more entries for generated files to
.gitignore(#4355, #4512). Thanks @dinomight and @localspook. -
Fixed various warnings and compilation issues (#4447, #4470, #4474, #4477, #4471, #4483, #4515, #4533, #4534). Thanks @dodomorandi, @localspook, @remyjette, @Tomek-Stolarczyk, @Mishura4, @mattiasljungstrom and @FatihBAKIR.
11.2.0
-
Added the
sspecifier forstd::error_code. It allows formatting an error message as a string. For example:#include <fmt/std.h> int main() { auto ec = std::make_error_code(std::errc::no_such_file_or_directory); fmt::print("{:s}\n", ec); }
prints
No such file or directory(The actual message is platform-specific.)
-
Fixed formatting of
std::chrono::local_timeandtm(#3815, #4350). For example (godbolt):#include <fmt/chrono.h> int main() { std::chrono::zoned_time zt( std::chrono::current_zone(), std::chrono::system_clock::now()); fmt::print("{}", zt.get_local_time()); }
is now formatted consistenly across platforms.
-
Added diagnostics for cases when timezone information is not available. For example:
fmt::print("{:Z}", std::chrono::local_seconds());
now gives a compile-time error.
-
Deprecated
fmt::localtimein favor ofstd::localtime. -
Fixed compilation with GCC 15 and C++20 modules enabled (#4347). Thanks @tkhyn.
-
Fixed handling of named arguments in format specs (#4360, #4361). Thanks @dinomight.
-
Added error reporting for duplicate named arguments (#4367). Thanks @dinomight.
-
Fixed formatting of
longwithFMT_BUILTIN_TYPES=0(#4375, #4394). -
Optimized
text_styleusing bit packing (#4363). Thanks @localspook. -
Added support for incomplete types (#3180, #4383). Thanks @localspook.
-
Fixed a flush issue in
fmt::printwhen using libstdc++ (#4398). -
Fixed
fmt::printlnusage withFMT_ENFORCE_COMPILE_STRINGand legacy compile-time checks (#4407). Thanks @madmaxoft. -
Removed legacy header
fmt/core.hfrom docs (#4421, #4422). Thanks @krzysztofkortas. -
Worked around limitations of
__builtin_strlenduring constant evaluation (#4423, #4429). Thanks @brevzin. -
Worked around a bug in MSVC v141 (#4412, #4413). Thanks @hirohira9119.
-
Removed the
fmt_detailnamespace (#4324). -
Removed specializations of
std::is_floating_pointin tests (#4417). -
Fixed a CMake error when setting
CMAKE_MODULE_PATHin the pedantic mode (#4426). Thanks @rlalik. -
Updated the Bazel config (#4400). Thanks @Vertexwahn.
11.1.4
-
Fixed ABI compatibility with earlier 11.x versions on Windows (#4359).
-
Improved the logic of switching between fixed and exponential format for
float(#3649). -
Moved
is_compiled_stringto the public API (#4342). Thanks @SwooshyCueb. -
Simplified implementation of
operator""_cf(#4349). Thanks @localspook. -
Fixed
__builtin_strlendetection (#4329). Thanks @localspook. -
Fixed handling of BMI paths with the Ninja generator (#4344). Thanks @tkhyn.
-
Fixed gcc 8.3 compile errors (#4331, #4336). Thanks @sergiud.
-
Fixed a bogus MSVC warning (#4356). Thanks @dinomight.
11.1.3
-
Fixed compilation on GCC 9.4 (#4313).
-
Worked around an internal compiler error when using C++20 modules with GCC 14.2 and earlier (#4295).
-
Worked around a bug in GCC 6 (#4318).
-
Fixed an issue caused by instantiating
formatter<const T>(#4303, #4325). Thanks @timsong-cpp. -
Fixed formatting into
std::ostreambuf_iteratorwhen using format string compilation (#4309, #4312). Thanks @phprus. -
Restored a constraint on the map formatter so that it correctly reports as unformattable when the element is (#4326). Thanks @timsong-cpp.
-
Reduced the size of format specs (#4298).
-
Readded
args()tofmt::format_context(#4307, #4310). Thanks @Erroneous1. -
Fixed a pedantic mode error in the CMake config (#4327). Thanks @rlalik.
11.1.2
-
Fixed ABI compatibility with earlier 11.x versions (#4292).
-
Added
wchar_tsupport to thestd::bitsetformatter (#4285, #4286, #4289, #4290). Thanks @phprus. -
Prefixed CMake components with
fmt-to simplify usage of {fmt} viaadd_subdirectory(#4283). -
Fixed a compilation error in chrono on nvcc (#4297, #4301). Thanks @breyerml.
-
Fixed various warnings (#4288, #4299). Thanks @GamesTrap and @edo9300.
11.1.1
11.1.0
-
Improved C++20 module support (#4081, #4083, #4084, #4152, #4153, #4169, #4190, #4234, #4239). Thanks @kamrann and @Arghnews.
-
Reduced debug (unoptimized) binary code size and the number of template instantiations when passing formatting arguments. For example, unoptimized binary code size for
fmt::print("{}", 42)was reduced by ~40% on GCC and ~60% on clang (x86-64).GCC:
- Before: 161 instructions of which 105 are in reusable functions (godbolt).
- After: 116 instructions of which 60 are in reusable functions (godbolt).
Clang:
-
Added an experimental
fmt::writerAPI that can be used for writing to different destinations such as files or strings (#2354). For example (godbolt):#include <fmt/os.h> void write_text(fmt::writer w) { w.print("The answer is {}.", 42); } int main() { // Write to FILE. write_text(stdout); // Write to fmt::ostream. auto f = fmt::output_file("myfile"); write_text(f); // Write to std::string. auto sb = fmt::string_buffer(); write_text(sb); std::string s = sb.str(); }
-
Added width and alignment support to the formatter of
std::error_code. -
Made
std::expected<void, E>formattable (#4145, #4148). For example (godbolt):fmt::print("{}", std::expected<void, int>());
prints
expected()Thanks @phprus.
-
Made
fmt::is_formattable<void>SFINAE-friendly (#4147). -
Added support for
_BitIntformatting when using clang (#4007, #4072, #4140, #4173, #4176). For example (godbolt):using int42 = _BitInt(42); fmt::print("{}", int42(100));
Thanks @Arghnews.
-
Added the
nspecifier for tuples and pairs (#4107). Thanks @someonewithpc. -
Added support for tuple-like types to
fmt::join(#4226, #4230). Thanks @phprus. -
Made more types formattable at compile time (#4127). Thanks @AnthonyVH.
-
Implemented a more efficient compile-time
fmt::formatted_size(#4102, #4103). Thanks @phprus. -
Fixed compile-time formatting of some string types (#4065). Thanks @torshepherd.
-
Made compiled version of
fmt::format_towork withstd::back_insert_iterator<std::vector<char>>(#4206, #4211). Thanks @phprus. -
Added a formatter for
std::reference_wrapper(#4163, #4164). Thanks @yfeldblum and @phprus. -
Added experimental padding support (glibc
strftimeextension) to%m,%jand%Y(#4161). Thanks @KKhanhH. -
Made microseconds formatted as
usinstead ofΒ΅sif the Unicode support is disabled (#4088). -
Fixed an unreleased regression in transcoding of surrogate pairs (#4094, #4095). Thanks @phprus.
-
Made
fmt::appendersatisfystd::output_iteratorconcept (#4092, #4093). Thanks @phprus. -
Made
std::iterator_traits<fmt::appender>standard-conforming (#4185). Thanks @CaseyCarter. -
Made it easier to reuse
fmt::formatter<std::string_view>for types with an implicit conversion tostd::string_view(#4036, #4055). Thanks @Arghnews. -
Made it possible to disable
<filesystem>use viaFMT_CPP_LIB_FILESYSTEMfor compatibility with some video game console SDKs, e.g. Nintendo Switch SDK (#4257, #4258, #4259). Thanks @W4RH4WK and @phprus. -
Fixed compatibility with platforms that use 80-bit
long double(#4245, #4246). Thanks @jsirpoma. -
Added support for UTF-32 code units greater than
0xFFFFin fill (#4201). -
Fixed handling of legacy encodings on Windows with GCC (#4162).
-
Made
fmt::to_stringtakefmt::basic_memory_bufferby const reference (#4261, #4262). Thanks @sascha-devel. -
Added
fmt::dynamic_format_arg_store::size(#4270). Thanks @hannes-harnisch. -
Removed the ability to control locale usage via an undocumented
FMT_STATIC_THOUSANDS_SEPARATORin favor ofFMT_USE_LOCALE. -
Renamed
FMT_EXCEPTIONStoFMT_USE_EXCEPTIONSfor consistency with other similar macros. -
Improved include directory ordering to reduce the chance of including incorrect headers when using multiple versions of {fmt} (#4116). Thanks @cdzhan.
-
Made it possible to compile a subset of {fmt} without the C++ runtime.
-
Improved documentation and README (#4066, #4117, #4203, #4235). Thanks @zyctree and @nikola-sh.
-
Improved the documentation generator (#4110, #4115). Thanks @rturrado.
-
Fixed various warnings and compilation issues (#2708, #4091, #4109, #4113, #4125, #4129, #4130, #4131, #4132, #4133, #4144, #4150, #4158, #4159, #4160, #4170, #4177, #4187, #4188, #4194, #4200, #4205, #4207, #4208, #4210, #4220, #4231, #4232, #4233, #4236, #4267, #4271). Thanks @torsten48, @Arghnews, @tinfoilboy, @aminya, @Ottani, @zeroomega, @c4v4, @kongy, @vinayyadav3016, @sergio-nsk, @phprus and @YexuanXiao.
11.0.2
-
Fixed performance regressions when using
std::back_insert_iteratorwithfmt::format_to(#4070). -
Fixed handling of
std::generatorand move-only iterators (#4053, #4057). Thanks @Arghnews. -
Made
formatter<std::string_view>::parsework with types convertible tostd::string_view(#4036, #4055). Thanks @Arghnews. -
Made
volatile void*formattable (#4049, #4056). Thanks @Arghnews. -
Made
Glib::ustringnot be confused withstd::string(#4052). -
Made
fmt::contextiterator compatible with STL algorithms that rely on iterator category (#4079).
11.0.1
-
Fixed version number in the inline namespace (#4047).
-
Fixed disabling Unicode support via CMake (#4051).
-
Fixed handling of a sign and improved the
std::complexformater (#4034, #4050). Thanks @tesch1 and @phprus. -
Fixed ADL issues in
fmt::printfwhen using C++20 (#4042). Thanks @toge. -
Removed a redundant check in the formatter for
std::expected(#4040). Thanks @phprus.
