10.2.0
-
Added support for the
%j
specifier (the number of days) forstd::chrono::duration
(#3643, #3732). Thanks @intelfx. -
Added support for the chrono suffix for days and changed the suffix for minutes from "m" to the correct "min" (#3662, #3664). For example (godbolt):
#include <fmt/chrono.h> int main() { fmt::print("{}\n", std::chrono::days(42)); // prints "42d" }
Thanks @Richardk2n.
-
Fixed an overflow in
std::chrono::time_point
formatting with large dates (#3725, #3727). Thanks @cschreib. -
Added a formatter for
std::source_location
(#3730). For example (godbolt):#include <source_location> #include <fmt/std.h> int main() { fmt::print("{}\n", std::source_location::current()); }
prints
/app/example.cpp:5:51: int main()
Thanks @felix642.
-
Added a formatter for
std::bitset
(#3660). For example (godbolt):#include <bitset> #include <fmt/std.h> int main() { fmt::print("{}\n", std::bitset<6>(42)); // prints "101010" }
Thanks @muggenhor.
-
Added an experimental
nested_formatter
that provides an easy way of applying a formatter to one or more subobjects while automatically handling width, fill and alignment. For example:#include <fmt/format.h> struct point { double x, y; }; template <> struct fmt::formatter<point> : nested_formatter<double> { auto format(point p, format_context& ctx) const { return write_padded(ctx, [=](auto out) { return format_to(out, "({}, {})", nested(p.x), nested(p.y)); }); } }; int main() { fmt::print("[{:>20.2f}]", point{1, 2}); }
prints
[ (1.00, 2.00)]
-
Added the generic representation (
g
) tostd::filesystem::path
(#3715, #3729). For example:#include <filesystem> #include <fmt/std.h> int main() { fmt::print("{:g}\n", std::filesystem::path("C:\\foo")); }
prints
"C:/foo"
on Windows.Thanks @js324.
-
Made
format_as
work with references (#3739). Thanks @tchaikov. -
Fixed formatting of invalid UTF-8 with precision (#3284).
-
Fixed an inconsistency between
fmt::to_string
andfmt::format
(#3684). -
Disallowed unsafe uses of
fmt::styled
(#3625):auto s = fmt::styled(std::string("dangle"), fmt::emphasis::bold); fmt::print("{}\n", s); // compile error
Pass
fmt::styled(...)
as a parameter instead. -
Added a null check when formatting a C string with the
s
specifier (#3706). -
Disallowed the
c
specifier forbool
(#3726, #3734). Thanks @js324. -
Made the default formatting unlocalized in
fmt::ostream_formatter
for consistency with the rest of the library (#3460). -
Fixed localized formatting in bases other than decimal (#3693, #3750). Thanks @js324.
-
Fixed a performance regression in experimental
fmt::ostream::print
(#3674). -
Added synchronization with the underlying output stream when writing to the Windows console (#3668, #3688, #3689). Thanks @Roman-Koshelev and @dimztimz.
-
Changed to only export
format_error
when {fmt} is built as a shared library (#3626, #3627). Thanks @phprus. -
Made
fmt::streamed
constexpr
. (#3650). Thanks @muggenhor. -
Enabled
consteval
on older versions of MSVC (#3757). Thanks @phprus. -
Added an option to build without
wchar_t
support on Windows (#3631, #3636). Thanks @glebm. -
Improved build and CI configuration (#3679, #3701, #3702, #3749). Thanks @jcar87, @pklima and @tchaikov.
-
Fixed various warnings, compilation and test issues (#3607, #3610, #3624, #3630, #3634, #3638, #3645, #3646, #3647, #3652, #3654, #3663, #3670, #3680, #3694, #3695, #3699, #3705, #3710, #3712, #3713, #3714, #3716, #3723, #3738, #3740, #3741, #3743, #3745, #3747, #3748, #3751, #3754, #3755, #3760, #3762, #3763, #3764, #3774, #3779). Thanks @danakj, @vinayyadav3016, @cyyever, @phprus, @qimiko, @saschasc, @gsjaardema, @lazka, @Zhaojun-Liu, @carlsmedstad, @hotwatermorning, @cptFracassa, @kuguma, @PeterJohnson, @H1X4Dev, @asantoni, @eltociear, @msimberg, @tchaikov, @waywardmonkeys.
-
Improved documentation and README (#2086, #3637, #3642, #3653, #3655, #3661, #3673, #3677, #3737, #3742, #3744). Thanks @idzm, @perlun, @joycebrum, @fennewald, @reinhardt1053, @GeorgeLS.
-
Updated CI dependencies (#3615, #3622, #3623, #3666, #3696, #3697, #3759, #3782).