Changelog History
Page 1
-
v9.1.0 Changes
August 27, 2022fmt::formatted_size
now works at compile time (#3026 <https://github.com/fmtlib/fmt/pull/3026>
). For example (godbolt <https://godbolt.org/z/1MW5rMdf8>
_):
.. code:: c++
#include <fmt/compile.h> int main() { using namespace fmt::literals; constexpr size_t n = fmt::formatted_size("{}"_cf, 42); fmt::print("{}\n", n); // prints 2 }
Thanks
@marksantaniello (Mark Santaniello) <https://github.com/marksantaniello>
_.๐ Fixed handling of invalid UTF-8 (
#3038 <https://github.com/fmtlib/fmt/pull/3038>
,#3044 <https://github.com/fmtlib/fmt/pull/3044>
,#3056 <https://github.com/fmtlib/fmt/pull/3056>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
and@skeeto (Christopher Wellons) <https://github.com/skeeto>
_.๐ Improved Unicode support in
ostream
overloads ofprint
(#2994 <https://github.com/fmtlib/fmt/pull/2994>
,#3001 <https://github.com/fmtlib/fmt/pull/3001>
,#3025 <https://github.com/fmtlib/fmt/pull/3025>
). Thanks@dimztimz (Dimitrij Mijoski) <https://github.com/dimztimz>
.๐ Fixed handling of the sign specifier in localized formatting on systems with 32-bit
wchar_t
(#3041 <https://github.com/fmtlib/fmt/issues/3041>
_).โ Added support for wide streams to
fmt::streamed
(#2994 <https://github.com/fmtlib/fmt/pull/2994>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.โ Added the
n
specifier that disables the output of delimiters when formatting ranges (#2981 <https://github.com/fmtlib/fmt/pull/2981>
,#2983 <https://github.com/fmtlib/fmt/pull/2983>
). For example (godbolt <https://godbolt.org/z/roKqGdj8c>
__):
.. code:: c++
#include <fmt/ranges.h> #include <vector> int main() { auto v = std::vector{1, 2, 3}; fmt::print("{:n}\n", v); // prints 1, 2, 3 }
Thanks
@BRevzin (Barry Revzin) <https://github.com/BRevzin>
_.Worked around problematic
std::string_view
constructors introduced in C++23 (#3030 <https://github.com/fmtlib/fmt/issues/3030>
,#3050 <https://github.com/fmtlib/fmt/issues/3050>
). Thanks@strega-nil-ms (nicole mazzuca) <https://github.com/strega-nil-ms>
_.๐ Improve handling (exclusion) of recursive ranges (
#2968 <https://github.com/fmtlib/fmt/issues/2968>
,#2974 <https://github.com/fmtlib/fmt/pull/2974>
). Thanks@Dani-Hub (Daniel Krรผgler) <https://github.com/Dani-Hub>
_.๐ Improved error reporting in format string compilation (
#3055 <https://github.com/fmtlib/fmt/issues/3055>
_).๐ Improved the implementation of
Dragonbox <https://github.com/jk-jeon/dragonbox>
, the algorithm used for the default floating-point formatting (#2984 <https://github.com/fmtlib/fmt/pull/2984>
). Thanks@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
_.๐ Fixed issues with floating-point formatting on exotic platforms.
๐ Improved the implementation of chrono formatting (
#3010 <https://github.com/fmtlib/fmt/pull/3010>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.๐ Improved documentation (
#2966 <https://github.com/fmtlib/fmt/pull/2966>
,#3009 <https://github.com/fmtlib/fmt/pull/3009>
,#3020 <https://github.com/fmtlib/fmt/issues/3020>
,#3037 <https://github.com/fmtlib/fmt/pull/3037>
). Thanks@mwinterb <https://github.com/mwinterb>
,@jcelerier (Jean-Michaรซl Celerier) <https://github.com/jcelerier>
and@remiburtin (Rรฉmi Burtin) <https://github.com/remiburtin>
_.๐ Improved build configuration (
#2991 <https://github.com/fmtlib/fmt/pull/2991>
,#2995 <https://github.com/fmtlib/fmt/pull/2995>
,#3004 <https://github.com/fmtlib/fmt/issues/3004>
,#3007 <https://github.com/fmtlib/fmt/pull/3007>
,#3040 <https://github.com/fmtlib/fmt/pull/3040>
). Thanks@dimztimz (Dimitrij Mijoski) <https://github.com/dimztimz>
and@hwhsu1231 (Haowei Hsu) <https://github.com/hwhsu1231>
_.๐ Fixed various warnings and compilation issues (
#2969 <https://github.com/fmtlib/fmt/issues/2969>
,#2971 <https://github.com/fmtlib/fmt/pull/2971>
,#2975 <https://github.com/fmtlib/fmt/issues/2975>
,#2982 <https://github.com/fmtlib/fmt/pull/2982>
,#2985 <https://github.com/fmtlib/fmt/pull/2985>
,#2988 <https://github.com/fmtlib/fmt/issues/2988>
,#3000 <https://github.com/fmtlib/fmt/issues/3000>
,#3006 <https://github.com/fmtlib/fmt/issues/3006>
,#3014 <https://github.com/fmtlib/fmt/issues/3014>
,#3015 <https://github.com/fmtlib/fmt/issues/3015>
,#3021 <https://github.com/fmtlib/fmt/pull/3021>
,#3023 <https://github.com/fmtlib/fmt/issues/3023>
,#3024 <https://github.com/fmtlib/fmt/pull/3024>
,#3029 <https://github.com/fmtlib/fmt/pull/3029>
,#3043 <https://github.com/fmtlib/fmt/pull/3043>
,#3052 <https://github.com/fmtlib/fmt/issues/3052>
,#3053 <https://github.com/fmtlib/fmt/pull/3053>
,#3054 <https://github.com/fmtlib/fmt/pull/3054>
). Thanks@h-friederich (Hannes Friederich) <https://github.com/h-friederich>
,@dimztimz (Dimitrij Mijoski) <https://github.com/dimztimz>
,@olupton (Olli Lupton) <https://github.com/olupton>
,@bernhardmgruber (Bernhard Manfred Gruber) <https://github.com/bernhardmgruber>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.
-
v9.0.0 Changes
July 04, 2022Switched to the internal floating point formatter for all decimal presentation formats. In particular this results in consistent rounding on all platforms and removing the
s[n]printf
fallback for decimal FP formatting.Compile-time floating point formatting no longer requires the header-only mode. For example (
godbolt <https://godbolt.org/z/G37PTeG3b>
__):
.. code:: c++
#include <array> #include <fmt/compile.h> consteval auto compile_time_dtoa(double value) -> std::array<char, 10> { auto result = std::array<char, 10>(); fmt::format_to(result.data(), FMT_COMPILE("{}"), value); return result; } constexpr auto answer = compile_time_dtoa(0.42);
works with the default settings.
๐ Improved the implementation of
Dragonbox <https://github.com/jk-jeon/dragonbox>
, the algorithm used for the default floating-point formatting (#2713 <https://github.com/fmtlib/fmt/pull/2713>
,#2750 <https://github.com/fmtlib/fmt/pull/2750>
). Thanks@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
.Made
fmt::to_string
work with__float128
. This uses the internal FP formatter and works even on system without__float128
support in[s]printf
.Disabled automatic
std::ostream
insertion operator (operator<<
) discovery whenfmt/ostream.h
is included to prevent ODR violations. You can get the old behavior by definingFMT_DEPRECATED_OSTREAM
but this will be removed in the next major release. Usefmt::streamed
orfmt::ostream_formatter
to enable formatting viastd::ostream
instead.โ Added
fmt::ostream_formatter
that can be used to writeformatter
specializations that perform formatting viastd::ostream
. For example (godbolt <https://godbolt.org/z/5sEc5qMsf>
__):
.. code:: c++
#include <fmt/ostream.h> struct date { int year, month, day; friend std::ostream& operator<<(std::ostream& os, const date& d) { return os << d.year << '-' << d.month << '-' << d.day; } }; template <> struct fmt::formatter<date> : ostream_formatter {}; std::string s = fmt::format("The date is {}", date{2012, 12, 9}); // s == "The date is 2012-12-9"
- โ Added the
fmt::streamed
function that takes an object and formats it viastd::ostream
. For example (godbolt <https://godbolt.org/z/5G3346G1f>
__):
.. code:: c++
#include <thread> #include <fmt/ostream.h> int main() { fmt::print("Current thread id: {}\n", fmt::streamed(std::this_thread::get_id())); }
Note that
fmt/std.h
provides aformatter
specialization forstd::thread::id
so you don't need to format it viastd::ostream
.๐ Deprecated implicit conversions of unscoped enums to integers for consistency with scoped enums.
โ Added an argument-dependent lookup based
format_as
extension API to simplify formatting of enums.โ Added experimental
std::variant
formatting support (#2941 <https://github.com/fmtlib/fmt/pull/2941>
). For example (godbolt <https://godbolt.org/z/KG9z6cq68>
_):
.. code:: c++
#include <variant> #include <fmt/std.h> int main() { auto v = std::variant<int, std::string>(42); fmt::print("{}\n", v); }
prints::
variant(42)
Thanks
@jehelset <https://github.com/jehelset>
_.- โ Added experimental
std::filesystem::path
formatting support (#2865 <https://github.com/fmtlib/fmt/issues/2865>
,#2902 <https://github.com/fmtlib/fmt/pull/2902>
,#2917 <https://github.com/fmtlib/fmt/issues/2917>
,#2918 <https://github.com/fmtlib/fmt/pull/2918>
). For example (godbolt <https://godbolt.org/z/o44dMexEb>
__):
.. code:: c++
#include <filesystem> #include <fmt/std.h> int main() { fmt::print("There is no place like {}.", std::filesystem::path("/home")); }
prints::
There is no place like "/home".
Thanks
@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.- โ Added a
std::thread::id
formatter tofmt/std.h
. For example (godbolt <https://godbolt.org/z/j1azbYf3E>
__):
.. code:: c++
#include <thread> #include <fmt/std.h> int main() { fmt::print("Current thread id: {}\n", std::this_thread::get_id()); }
- โ Added
fmt::styled
that applies a text style to an individual argument (#2793 <https://github.com/fmtlib/fmt/pull/2793>
). For example (godbolt <https://godbolt.org/z/vWGW7v5M6>
_):
.. code:: c++
#include <fmt/chrono.h> #include <fmt/color.h> int main() { auto now = std::chrono::system_clock::now(); fmt::print( "[{}] {}: {}\n", fmt::styled(now, fmt::emphasis::bold), fmt::styled("error", fg(fmt::color::red)), "something went wrong"); }
prints
.. image:: https://user-images.githubusercontent.com/576385/ 175071215-12809244-dab0-4005-96d8-7cd911c964d5.png
Thanks
@rbrugo (Riccardo Brugo) <https://github.com/rbrugo>
_.๐ Made
fmt::print
overload for text styles correctly handle UTF-8 (#2681 <https://github.com/fmtlib/fmt/issues/2681>
,#2701 <https://github.com/fmtlib/fmt/pull/2701>
). Thanks@AlexGuteniev (Alex Guteniev) <https://github.com/AlexGuteniev>
_.๐ Fixed Unicode handling when writing to an ostream.
โ Added support for nested specifiers to range formatting (
#2673 <https://github.com/fmtlib/fmt/pull/2673>
). For example (godbolt <https://godbolt.org/z/xd3Gj38cf>
_):
.. code:: c++
#include <vector> #include <fmt/ranges.h> int main() { fmt::print("{::#x}\n", std::vector{10, 20, 30}); }
prints
[0xa, 0x14, 0x1e]
.Thanks
@BRevzin (Barry Revzin) <https://github.com/BRevzin>
_.Implemented escaping of wide strings in ranges (
#2904 <https://github.com/fmtlib/fmt/pull/2904>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.โ Added support for ranges with
begin
/end
found via the argument-dependent lookup (#2807 <https://github.com/fmtlib/fmt/pull/2807>
). Thanks@rbrugo (Riccardo Brugo) <https://github.com/rbrugo>
.๐ Fixed formatting of certain kinds of ranges of ranges (
#2787 <https://github.com/fmtlib/fmt/pull/2787>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
.๐ Fixed handling of maps with element types other than
std::pair
(#2944 <https://github.com/fmtlib/fmt/pull/2944>
). Thanks@BrukerJWD (Jonathan W) <https://github.com/BrukerJWD>
.Made tuple formatter enabled only if elements are formattable (
#2939 <https://github.com/fmtlib/fmt/issues/2939>
,#2940 <https://github.com/fmtlib/fmt/pull/2940>
). Thanks@jehelset <https://github.com/jehelset>
_.Made
fmt::join
compatible with format string compilation (#2719 <https://github.com/fmtlib/fmt/issues/2719>
,#2720 <https://github.com/fmtlib/fmt/pull/2720>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.Made compile-time checks work with named arguments of custom types and
std::ostream
print
overloads (#2816 <https://github.com/fmtlib/fmt/issues/2816>
,#2817 <https://github.com/fmtlib/fmt/issues/2817>
,#2819 <https://github.com/fmtlib/fmt/pull/2819>
). Thanks@timsong-cpp <https://github.com/timsong-cpp>
.Removed
make_args_checked
because it is no longer needed for compile-time checks (#2760 <https://github.com/fmtlib/fmt/pull/2760>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.Removed the following deprecated APIs:
_format
,arg_join
, theformat_to
overload that takes a memory buffer,[v]fprintf
that takes anostream
.โ Removed the deprecated implicit conversion of
[const] signed char*
and[const] unsigned char*
to C strings.โ Removed the deprecated
fmt/locale.h
.๐ Replaced the deprecated
fileno()
withdescriptor()
inbuffered_file
.Moved
to_string_view
to thedetail
namespace since it's an implementation detail.Made access mode of a created file consistent with
fopen
by settingS_IWGRP
andS_IWOTH
(#2733 <https://github.com/fmtlib/fmt/pull/2733>
). Thanks@arogge (Andreas Rogge) <https://github.com/arogge>
.โ Removed a redundant buffer resize when formatting to
std::ostream
(#2842 <https://github.com/fmtlib/fmt/issues/2842>
,#2843 <https://github.com/fmtlib/fmt/pull/2843>
). Thanks@jcelerier (Jean-Michaรซl Celerier) <https://github.com/jcelerier>
_.Made precision computation for strings consistent with width (
#2888 <https://github.com/fmtlib/fmt/issues/2888>
_).๐ Fixed handling of locale separators in floating point formatting (
#2830 <https://github.com/fmtlib/fmt/issues/2830>
_).Made sign specifiers work with
__int128_t
(#2773 <https://github.com/fmtlib/fmt/issues/2773>
_).๐ Improved support for systems such as CHERI with extra data stored in pointers (
#2932 <https://github.com/fmtlib/fmt/pull/2932>
). Thanks@davidchisnall (David Chisnall) <https://github.com/davidchisnall>
.๐ Improved documentation (
#2706 <https://github.com/fmtlib/fmt/pull/2706>
,#2712 <https://github.com/fmtlib/fmt/pull/2712>
,#2789 <https://github.com/fmtlib/fmt/pull/2789>
,#2803 <https://github.com/fmtlib/fmt/pull/2803>
,#2805 <https://github.com/fmtlib/fmt/pull/2805>
,#2815 <https://github.com/fmtlib/fmt/pull/2815>
,#2924 <https://github.com/fmtlib/fmt/pull/2924>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
,@Pokechu22 <https://github.com/Pokechu22>
,@setoye (Alta) <https://github.com/setoye>
,@rtobar <https://github.com/rtobar>
,@rbrugo (Riccardo Brugo) <https://github.com/rbrugo>
,@anoonD (cre) <https://github.com/anoonD>
,@leha-bot (Alex) <https://github.com/leha-bot>
.๐ Improved build configuration (
#2766 <https://github.com/fmtlib/fmt/pull/2766>
,#2772 <https://github.com/fmtlib/fmt/pull/2772>
,#2836 <https://github.com/fmtlib/fmt/pull/2836>
,#2852 <https://github.com/fmtlib/fmt/pull/2852>
,#2907 <https://github.com/fmtlib/fmt/pull/2907>
,#2913 <https://github.com/fmtlib/fmt/pull/2913>
,#2914 <https://github.com/fmtlib/fmt/pull/2914>
). Thanks@kambala-decapitator (Andrey Filipenkov) <https://github.com/kambala-decapitator>
,@mattiasljungstrom (Mattias Ljungstrรถm) <https://github.com/mattiasljungstrom>
,@kieselnb (Nick Kiesel) <https://github.com/kieselnb>
,@nathannaveen <https://github.com/nathannaveen>
,@Vertexwahn <https://github.com/Vertexwahn>
.๐ Fixed various warnings and compilation issues (
#2408 <https://github.com/fmtlib/fmt/issues/2408>
,#2507 <https://github.com/fmtlib/fmt/issues/2507>
,#2697 <https://github.com/fmtlib/fmt/issues/2697>
,#2715 <https://github.com/fmtlib/fmt/issues/2715>
,#2717 <https://github.com/fmtlib/fmt/issues/2717>
,#2722 <https://github.com/fmtlib/fmt/pull/2722>
,#2724 <https://github.com/fmtlib/fmt/pull/2724>
,#2725 <https://github.com/fmtlib/fmt/pull/2725>
,#2726 <https://github.com/fmtlib/fmt/issues/2726>
,#2728 <https://github.com/fmtlib/fmt/pull/2728>
,#2732 <https://github.com/fmtlib/fmt/pull/2732>
,#2738 <https://github.com/fmtlib/fmt/issues/2738>
,#2742 <https://github.com/fmtlib/fmt/pull/2742>
,#2744 <https://github.com/fmtlib/fmt/issues/2744>
,#2745 <https://github.com/fmtlib/fmt/issues/2745>
,#2746 <https://github.com/fmtlib/fmt/issues/2746>
,#2754 <https://github.com/fmtlib/fmt/issues/2754>
,#2755 <https://github.com/fmtlib/fmt/pull/2755>
,#2757 <https://github.com/fmtlib/fmt/issues/2757>
,#2758 <https://github.com/fmtlib/fmt/pull/2758>
,#2761 <https://github.com/fmtlib/fmt/issues/2761>
,#2762 <https://github.com/fmtlib/fmt/pull/2762>
,#2763 <https://github.com/fmtlib/fmt/issues/2763>
,#2765 <https://github.com/fmtlib/fmt/pull/2765>
,#2769 <https://github.com/fmtlib/fmt/issues/2769>
,#2770 <https://github.com/fmtlib/fmt/pull/2770>
,#2771 <https://github.com/fmtlib/fmt/issues/2771>
,#2777 <https://github.com/fmtlib/fmt/issues/2777>
,#2779 <https://github.com/fmtlib/fmt/pull/2779>
,#2782 <https://github.com/fmtlib/fmt/pull/2782>
,#2783 <https://github.com/fmtlib/fmt/pull/2783>
,#2794 <https://github.com/fmtlib/fmt/issues/2794>
,#2796 <https://github.com/fmtlib/fmt/issues/2796>
,#2797 <https://github.com/fmtlib/fmt/pull/2797>
,#2801 <https://github.com/fmtlib/fmt/pull/2801>
,#2802 <https://github.com/fmtlib/fmt/pull/2802>
,#2808 <https://github.com/fmtlib/fmt/issues/2808>
,#2818 <https://github.com/fmtlib/fmt/issues/2818>
,#2819 <https://github.com/fmtlib/fmt/pull/2819>
,#2829 <https://github.com/fmtlib/fmt/issues/2829>
,#2835 <https://github.com/fmtlib/fmt/issues/2835>
,#2848 <https://github.com/fmtlib/fmt/issues/2848>
,#2860 <https://github.com/fmtlib/fmt/issues/2860>
,#2861 <https://github.com/fmtlib/fmt/pull/2861>
,#2882 <https://github.com/fmtlib/fmt/pull/2882>
,#2886 <https://github.com/fmtlib/fmt/issues/2886>
,#2891 <https://github.com/fmtlib/fmt/issues/2891>
,#2892 <https://github.com/fmtlib/fmt/pull/2892>
,#2895 <https://github.com/fmtlib/fmt/issues/2895>
,#2896 <https://github.com/fmtlib/fmt/issues/2896>
,#2903 <https://github.com/fmtlib/fmt/pull/2903>
,#2906 <https://github.com/fmtlib/fmt/issues/2906>
,#2908 <https://github.com/fmtlib/fmt/issues/2908>
,#2909 <https://github.com/fmtlib/fmt/pull/2909>
,#2920 <https://github.com/fmtlib/fmt/issues/2920>
,#2922 <https://github.com/fmtlib/fmt/pull/2922>
,#2927 <https://github.com/fmtlib/fmt/pull/2927>
,#2929 <https://github.com/fmtlib/fmt/pull/2929>
,#2936 <https://github.com/fmtlib/fmt/issues/2936>
,#2937 <https://github.com/fmtlib/fmt/pull/2937>
,#2938 <https://github.com/fmtlib/fmt/pull/2938>
,#2951 <https://github.com/fmtlib/fmt/pull/2951>
,#2954 <https://github.com/fmtlib/fmt/issues/2954>
,#2957 <https://github.com/fmtlib/fmt/pull/2957>
,#2958 <https://github.com/fmtlib/fmt/issues/2958>
,#2960 <https://github.com/fmtlib/fmt/pull/2960>
). Thanks@matrackif <https://github.com/matrackif>
_@Tobi823 (Tobias Hellmann) <https://github.com/Tobi823>
,@ivan-volnov (Ivan Volnov) <https://github.com/ivan-volnov>
,@VasiliPupkin256 <https://github.com/VasiliPupkin256>
,@federico-busato (Federico) <https://github.com/federico-busato>
,@barcharcraz (Charlie Barto) <https://github.com/barcharcraz>
,@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
,@HazardyKnusperkeks (Bjรถrn Schรคpers) <https://github.com/HazardyKnusperkeks>
,@dalboris (Boris Dalstein) <https://github.com/dalboris>
,@seanm (Sean McBride) <https://github.com/seanm>
,@gsjaardema (Greg Sjaardema) <https://github.com/gsjaardema>
,@timsong-cpp <https://github.com/timsong-cpp>
,@seanm (Sean McBride) <https://github.com/seanm>
,@frithrah <https://github.com/frithrah>
,@chronoxor (Ivan Shynkarenka) <https://github.com/chronoxor>
,@Agga <https://github.com/Agga>
,@madmaxoft (Mattes D) <https://github.com/madmaxoft>
,@JurajX (Juraj) <https://github.com/JurajX>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
,@Dani-Hub (Daniel Krรผgler) <https://github.com/Dani-Hub>
_.
-
v8.1.1 Changes
January 06, 2022โช Restored ABI compatibility with version 8.0.x (
#2695 <https://github.com/fmtlib/fmt/issues/2695>
,#2696 <https://github.com/fmtlib/fmt/pull/2696>
). Thanks@saraedum (Julian Rรผth) <https://github.com/saraedum>
_.๐ Fixed chrono formatting on big endian systems (
#2698 <https://github.com/fmtlib/fmt/issues/2698>
,#2699 <https://github.com/fmtlib/fmt/pull/2699>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
_ and@xvitaly (Vitaly Zaitsev) <https://github.com/xvitaly>
_.๐ Fixed a linkage error with mingw (
#2691 <https://github.com/fmtlib/fmt/issues/2691>
,#2692 <https://github.com/fmtlib/fmt/pull/2692>
). Thanks@rbberger (Richard Berger) <https://github.com/rbberger>
_.
-
v8.1.0 Changes
January 02, 2022- โก๏ธ Optimized chrono formatting
(
#2500 <https://github.com/fmtlib/fmt/pull/2500>
,#2537 <https://github.com/fmtlib/fmt/pull/2537>
,#2541 <https://github.com/fmtlib/fmt/issues/2541>
,#2544 <https://github.com/fmtlib/fmt/pull/2544>
,#2550 <https://github.com/fmtlib/fmt/pull/2550>
,#2551 <https://github.com/fmtlib/fmt/pull/2551>
,#2576 <https://github.com/fmtlib/fmt/pull/2576>
,#2577 <https://github.com/fmtlib/fmt/issues/2577>
,#2586 <https://github.com/fmtlib/fmt/pull/2586>
,#2591 <https://github.com/fmtlib/fmt/pull/2591>
,#2594 <https://github.com/fmtlib/fmt/pull/2594>
,#2602 <https://github.com/fmtlib/fmt/pull/2602>
,#2617 <https://github.com/fmtlib/fmt/pull/2617>
,#2628 <https://github.com/fmtlib/fmt/issues/2628>
,#2633 <https://github.com/fmtlib/fmt/pull/2633>
,#2670 <https://github.com/fmtlib/fmt/issues/2670>
,#2671 <https://github.com/fmtlib/fmt/pull/2671>
_).
Processing of some specifiers such as
%z
and%Y
is now up to 10-20 times faster, for example on GCC 11 with libstdc++::---------------------------------------------------------------------------- Benchmark Before After ---------------------------------------------------------------------------- FMTFormatter_z 261 ns 26.3 ns FMTFormatterCompile_z 246 ns 11.6 ns FMTFormatter_Y 263 ns 26.1 ns FMTFormatterCompile_Y 244 ns 10.5 ns ----------------------------------------------------------------------------
Thanks
@phprus (Vladislav Shchapov) <https://github.com/phprus>
_ and@toughengineer (Pavel Novikov) <https://github.com/toughengineer>
_.- Implemented subsecond formatting for chrono durations
(
#2623 <https://github.com/fmtlib/fmt/pull/2623>
). For example (godbolt <https://godbolt.org/z/es7vWTETe>
_):
.. code:: c++
#include <fmt/chrono.h> int main() { fmt::print("{:%S}", std::chrono::milliseconds(1234)); }
prints "01.234".
Thanks
@matrackif <https://github.com/matrackif>
_.๐ Fixed handling of precision 0 when formatting chrono durations (
#2587 <https://github.com/fmtlib/fmt/issues/2587>
,#2588 <https://github.com/fmtlib/fmt/pull/2588>
). Thanks@lukester1975 <https://github.com/lukester1975>
_.๐ Fixed an overflow on invalid inputs in the
tm
formatter (#2564 <https://github.com/fmtlib/fmt/pull/2564>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.โ Added
fmt::group_digits
that formats integers with a non-localized digit separator (comma) for groups of three digits. For example (godbolt <https://godbolt.org/z/TxGxG9Poq>
__):
.. code:: c++
#include <fmt/format.h> int main() { fmt::print("{} dollars", fmt::group_digits(1000000)); }
prints "1,000,000 dollars".
- โ Added support for faint, conceal, reverse and blink text styles
(
#2394 <https://github.com/fmtlib/fmt/pull/2394>
_):
https://user-images.githubusercontent.com/576385/147710227-c68f5317-f8fa-42c3-9123-7c4ba3c398cb.mp4
Thanks
@benit8 (Benoรฎt Lormeau) <https://github.com/benit8>
_ and@data-man (Dmitry Atamanov) <https://github.com/data-man>
_.โ Added experimental support for compile-time floating point formatting (
#2426 <https://github.com/fmtlib/fmt/pull/2426>
,#2470 <https://github.com/fmtlib/fmt/pull/2470>
). It is currently limited to the header-only mode. Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.โ Added UDL-based named argument support to compile-time format string checks (
#2640 <https://github.com/fmtlib/fmt/issues/2640>
,#2649 <https://github.com/fmtlib/fmt/pull/2649>
). For example (godbolt <https://godbolt.org/z/ohGbbvonv>
__):
.. code:: c++
#include <fmt/format.h> int main() { using namespace fmt::literals; fmt::print("{answer:s}", "answer"_a=42); }
gives a compile-time error on compilers with C++20
consteval
and non-type template parameter support (gcc 10+) becauses
is not a valid format specifier for an integer.Thanks
@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.- Implemented escaping of string range elements.
For example (
godbolt <https://godbolt.org/z/rKvM1vKf3>
__):
.. code:: c++
#include <fmt/ranges.h> #include <vector> int main() { fmt::print("{}", std::vector<std::string>{"\naan"}); }
is now printed as::
["\naan"]
instead of::
[" aan"]
โ Added an experimental
?
specifier for escaping strings. (#2674 <https://github.com/fmtlib/fmt/pull/2674>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
.Switched to JSON-like representation of maps and sets for consistency with Python's
str.format
. For example (godbolt <https://godbolt.org/z/seKjoY9W5>
__):
.. code:: c++
#include <fmt/ranges.h> #include <map> int main() { fmt::print("{}", std::map<std::string, int>{{"answer", 42}}); }
is now printed as::
{"answer": 42}
๐ Extended
fmt::join
to support C++20-only ranges (#2549 <https://github.com/fmtlib/fmt/pull/2549>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
.โก๏ธ Optimized handling of non-const-iterable ranges and implemented initial support for non-const-formattable types.
Disabled implicit conversions of scoped enums to integers that was accidentally introduced in earlier versions (
#1841 <https://github.com/fmtlib/fmt/pull/1841>
_).๐ Deprecated implicit conversion of
[const] signed char*
and[const] unsigned char*
to C strings.๐ Deprecated
_format
, a legacy UDL-based format API (#2646 <https://github.com/fmtlib/fmt/pull/2646>
). Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
.Marked
format
,formatted_size
andto_string
as[[nodiscard]]
(#2612 <https://github.com/fmtlib/fmt/pull/2612>
).@0x8000-0000 (Florin Iucha) <https://github.com/0x8000-0000>
.โ Added missing diagnostic when trying to format function and member pointers as well as objects convertible to pointers which is explicitly disallowed (
#2598 <https://github.com/fmtlib/fmt/issues/2598>
,#2609 <https://github.com/fmtlib/fmt/pull/2609>
,#2610 <https://github.com/fmtlib/fmt/pull/2610>
). Thanks@AlexGuteniev (Alex Guteniev) <https://github.com/AlexGuteniev>
.Optimized writing to a contiguous buffer with
format_to_n
(#2489 <https://github.com/fmtlib/fmt/pull/2489>
). Thanks@Roman-Koshelev <https://github.com/Roman-Koshelev>
.โก๏ธ Optimized writing to non-
char
buffers (#2477 <https://github.com/fmtlib/fmt/pull/2477>
). Thanks@Roman-Koshelev <https://github.com/Roman-Koshelev>
.Decimal point is now localized when using the
L
specifier.๐ Improved floating point formatter implementation (
#2498 <https://github.com/fmtlib/fmt/pull/2498>
,#2499 <https://github.com/fmtlib/fmt/pull/2499>
). Thanks@Roman-Koshelev <https://github.com/Roman-Koshelev>
_.๐ Fixed handling of very large precision in fixed format (
#2616 <https://github.com/fmtlib/fmt/pull/2616>
_).Made a table of cached powers used in FP formatting static (
#2509 <https://github.com/fmtlib/fmt/pull/2509>
). Thanks@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
.Resolved a lookup ambiguity with C++20 format-related functions due to ADL (
#2639 <https://github.com/fmtlib/fmt/issues/2639>
,#2641 <https://github.com/fmtlib/fmt/pull/2641>
). Thanks@mkurdej (Marek Kurdej) <https://github.com/mkurdej>
_.โ Removed unnecessary inline namespace qualification (
#2642 <https://github.com/fmtlib/fmt/issues/2642>
,#2643 <https://github.com/fmtlib/fmt/pull/2643>
). Thanks@mkurdej (Marek Kurdej) <https://github.com/mkurdej>
_.Implemented argument forwarding in
format_to_n
(#2462 <https://github.com/fmtlib/fmt/issues/2462>
,#2463 <https://github.com/fmtlib/fmt/pull/2463>
). Thanks@owent (WenTao Ou) <https://github.com/owent>
_.๐ Fixed handling of implicit conversions in
fmt::to_string
and format string compilation (#2565 <https://github.com/fmtlib/fmt/issues/2565>
_).๐ Changed the default access mode of files created by
fmt::output_file
to-rw-r--r--
for consistency withfopen
(#2530 <https://github.com/fmtlib/fmt/issues/2530>
_).๐ Make
fmt::ostream::flush
public (#2435 <https://github.com/fmtlib/fmt/issues/2435>
_).๐ Improved C++14/17 attribute detection (
#2615 <https://github.com/fmtlib/fmt/pull/2615>
). Thanks@AlexGuteniev (Alex Guteniev) <https://github.com/AlexGuteniev>
.๐ Improved
consteval
detection for MSVC (#2559 <https://github.com/fmtlib/fmt/pull/2559>
). Thanks@DanielaE (Daniela Engert) <https://github.com/DanielaE>
.๐ Improved documentation (
#2406 <https://github.com/fmtlib/fmt/issues/2406>
,#2446 <https://github.com/fmtlib/fmt/pull/2446>
,#2493 <https://github.com/fmtlib/fmt/issues/2493>
,#2513 <https://github.com/fmtlib/fmt/issues/2513>
,#2515 <https://github.com/fmtlib/fmt/pull/2515>
,#2522 <https://github.com/fmtlib/fmt/issues/2522>
,#2562 <https://github.com/fmtlib/fmt/pull/2562>
,#2575 <https://github.com/fmtlib/fmt/pull/2575>
,#2606 <https://github.com/fmtlib/fmt/pull/2606>
,#2620 <https://github.com/fmtlib/fmt/pull/2620>
,#2676 <https://github.com/fmtlib/fmt/issues/2676>
). Thanks@sobolevn (Nikita Sobolev) <https://github.com/sobolevn>
,@UnePierre (Max FERGER) <https://github.com/UnePierre>
,@zhsj <https://github.com/zhsj>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
,@ericcurtin (Eric Curtin) <https://github.com/ericcurtin>
,@Lounarok <https://github.com/Lounarok>
_.๐ Improved fuzzers and added a fuzzer for chrono timepoint formatting (
#2461 <https://github.com/fmtlib/fmt/pull/2461>
,#2469 <https://github.com/fmtlib/fmt/pull/2469>
).@pauldreik (Paul Dreik) <https://github.com/pauldreik>
_,Added the
FMT_SYSTEM_HEADERS
CMake option setting which marks {fmt}'s headers as system. It can be used to suppress warnings (#2644 <https://github.com/fmtlib/fmt/issues/2644>
,#2651 <https://github.com/fmtlib/fmt/pull/2651>
). Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.โ Added the Bazel build system support (
#2505 <https://github.com/fmtlib/fmt/pull/2505>
,#2516 <https://github.com/fmtlib/fmt/pull/2516>
). Thanks@Vertexwahn <https://github.com/Vertexwahn>
_.๐ Improved build configuration and tests (
#2437 <https://github.com/fmtlib/fmt/issues/2437>
,#2558 <https://github.com/fmtlib/fmt/pull/2558>
,#2648 <https://github.com/fmtlib/fmt/pull/2648>
,#2650 <https://github.com/fmtlib/fmt/pull/2650>
,#2663 <https://github.com/fmtlib/fmt/pull/2663>
,#2677 <https://github.com/fmtlib/fmt/pull/2677>
). Thanks@DanielaE (Daniela Engert) <https://github.com/DanielaE>
,@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.๐ Fixed various warnings and compilation issues (
#2353 <https://github.com/fmtlib/fmt/pull/2353>
,#2356 <https://github.com/fmtlib/fmt/pull/2356>
,#2399 <https://github.com/fmtlib/fmt/pull/2399>
,#2408 <https://github.com/fmtlib/fmt/issues/2408>
,#2414 <https://github.com/fmtlib/fmt/pull/2414>
,#2427 <https://github.com/fmtlib/fmt/pull/2427>
,#2432 <https://github.com/fmtlib/fmt/pull/2432>
,#2442 <https://github.com/fmtlib/fmt/pull/2442>
,#2434 <https://github.com/fmtlib/fmt/pull/2434>
,#2439 <https://github.com/fmtlib/fmt/issues/2439>
,#2447 <https://github.com/fmtlib/fmt/pull/2447>
,#2450 <https://github.com/fmtlib/fmt/pull/2450>
,#2455 <https://github.com/fmtlib/fmt/issues/2455>
,#2465 <https://github.com/fmtlib/fmt/issues/2465>
,#2472 <https://github.com/fmtlib/fmt/issues/2472>
,#2474 <https://github.com/fmtlib/fmt/issues/2474>
,#2476 <https://github.com/fmtlib/fmt/pull/2476>
,#2478 <https://github.com/fmtlib/fmt/issues/2478>
,#2479 <https://github.com/fmtlib/fmt/issues/2479>
,#2481 <https://github.com/fmtlib/fmt/issues/2481>
,#2482 <https://github.com/fmtlib/fmt/pull/2482>
,#2483 <https://github.com/fmtlib/fmt/pull/2483>
,#2490 <https://github.com/fmtlib/fmt/issues/2490>
,#2491 <https://github.com/fmtlib/fmt/pull/2491>
,#2510 <https://github.com/fmtlib/fmt/pull/2510>
,#2518 <https://github.com/fmtlib/fmt/pull/2518>
,#2528 <https://github.com/fmtlib/fmt/issues/2528>
,#2529 <https://github.com/fmtlib/fmt/pull/2529>
,#2539 <https://github.com/fmtlib/fmt/pull/2539>
,#2540 <https://github.com/fmtlib/fmt/issues/2540>
,#2545 <https://github.com/fmtlib/fmt/pull/2545>
,#2555 <https://github.com/fmtlib/fmt/pull/2555>
,#2557 <https://github.com/fmtlib/fmt/issues/2557>
,#2570 <https://github.com/fmtlib/fmt/issues/2570>
,#2573 <https://github.com/fmtlib/fmt/pull/2573>
,#2582 <https://github.com/fmtlib/fmt/pull/2582>
,#2605 <https://github.com/fmtlib/fmt/issues/2605>
,#2611 <https://github.com/fmtlib/fmt/pull/2611>
,#2647 <https://github.com/fmtlib/fmt/pull/2647>
,#2627 <https://github.com/fmtlib/fmt/issues/2627>
,#2630 <https://github.com/fmtlib/fmt/pull/2630>
,#2635 <https://github.com/fmtlib/fmt/issues/2635>
,#2638 <https://github.com/fmtlib/fmt/issues/2638>
,#2653 <https://github.com/fmtlib/fmt/issues/2653>
,#2654 <https://github.com/fmtlib/fmt/issues/2654>
,#2661 <https://github.com/fmtlib/fmt/issues/2661>
,#2664 <https://github.com/fmtlib/fmt/pull/2664>
,#2684 <https://github.com/fmtlib/fmt/pull/2684>
). Thanks@DanielaE (Daniela Engert) <https://github.com/DanielaE>
,@mwinterb <https://github.com/mwinterb>
,@cdacamar (Cameron DaCamara) <https://github.com/cdacamar>
,@TrebledJ (Johnathan) <https://github.com/TrebledJ>
,@bodomartin (brm) <https://github.com/bodomartin>
,@cquammen (Cory Quammen) <https://github.com/cquammen>
,@white238 (Chris White) <https://github.com/white238>
,@mmarkeloff (Max) <https://github.com/mmarkeloff>
,@palacaze (Pierre-Antoine Lacaze) <https://github.com/palacaze>
,@jcelerier (Jean-Michaรซl Celerier) <https://github.com/jcelerier>
,@mborn-adi (Mathias Born) <https://github.com/mborn-adi>
,@BrukerJWD (Jonathan W) <https://github.com/BrukerJWD>
,@spyridon97 (Spiros Tsalikis) <https://github.com/spyridon97>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
,@oliverlee (Oliver Lee) <https://github.com/oliverlee>
,@joshessman-llnl (Josh Essman) <https://github.com/joshessman-llnl>
,@akohlmey (Axel Kohlmeyer) <https://github.com/akohlmey>
,@timkalu <https://github.com/timkalu>
,@olupton (Olli Lupton) <https://github.com/olupton>
,@Acretock <https://github.com/Acretock>
,@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
,@andrewcorrigan (Andrew Corrigan) <https://github.com/andrewcorrigan>
,@lucpelletier <https://github.com/lucpelletier>
,@HazardyKnusperkeks (Bjรถrn Schรคpers) <https://github.com/HazardyKnusperkeks>
.
- โก๏ธ Optimized chrono formatting
(
-
v8.0.1 Changes
July 02, 2021๐ Fixed the version number in the inline namespace (
#2374 <https://github.com/fmtlib/fmt/issues/2374>
_).โ Added a missing presentation type check for
std::string
(#2402 <https://github.com/fmtlib/fmt/issues/2402>
_).๐ Fixed a linkage error when mixing code built with clang and gcc (
#2377 <https://github.com/fmtlib/fmt/issues/2377>
_).๐ Fixed documentation issues (
#2396 <https://github.com/fmtlib/fmt/pull/2396>
,#2403 <https://github.com/fmtlib/fmt/issues/2403>
,#2406 <https://github.com/fmtlib/fmt/issues/2406>
). Thanks@mkurdej (Marek Kurdej) <https://github.com/mkurdej>
.โ Removed dead code in FP formatter (
#2398 <https://github.com/fmtlib/fmt/pull/2398>
). Thanks@javierhonduco (Javier Honduvilla Coto) <https://github.com/javierhonduco>
.๐ Fixed various warnings and compilation issues (
#2351 <https://github.com/fmtlib/fmt/issues/2351>
,#2359 <https://github.com/fmtlib/fmt/issues/2359>
,#2365 <https://github.com/fmtlib/fmt/pull/2365>
,#2368 <https://github.com/fmtlib/fmt/issues/2368>
,#2370 <https://github.com/fmtlib/fmt/pull/2370>
,#2376 <https://github.com/fmtlib/fmt/pull/2376>
,#2381 <https://github.com/fmtlib/fmt/pull/2381>
,#2382 <https://github.com/fmtlib/fmt/pull/2382>
,#2386 <https://github.com/fmtlib/fmt/issues/2386>
,#2389 <https://github.com/fmtlib/fmt/pull/2389>
,#2395 <https://github.com/fmtlib/fmt/pull/2395>
,#2397 <https://github.com/fmtlib/fmt/pull/2397>
,#2400 <https://github.com/fmtlib/fmt/issues/2400>
,#2401 <https://github.com/fmtlib/fmt/issues/2401>
,#2407 <https://github.com/fmtlib/fmt/pull/2407>
). Thanks@zx2c4 (Jason A. Donenfeld) <https://github.com/zx2c4>
,@AidanSun05 (Aidan Sun) <https://github.com/AidanSun05>
,@mattiasljungstrom (Mattias Ljungstrรถm) <https://github.com/mattiasljungstrom>
,@joemmett (Jonathan Emmett) <https://github.com/joemmett>
,@erengy (Eren Okka) <https://github.com/erengy>
,@patlkli (Patrick Geltinger) <https://github.com/patlkli>
,@gsjaardema (Greg Sjaardema) <https://github.com/gsjaardema>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.
-
v8.0.0 Changes
June 21, 2021- 0๏ธโฃ Enabled compile-time format string checks by default.
For example (
godbolt <https://godbolt.org/z/sMxcohGjz>
__):
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{:d}", "I am not a number"); }
gives a compile-time error on compilers with C++20
consteval
support (gcc 10+, clang 11+) becaused
is not a valid format specifier for a string.To pass a runtime string wrap it in
fmt::runtime
:.. code:: c++
fmt::print(fmt::runtime("{:d}"), "I am not a number");
- โ Added compile-time formatting
(
#2019 <https://github.com/fmtlib/fmt/pull/2019>
,#2044 <https://github.com/fmtlib/fmt/pull/2044>
,#2056 <https://github.com/fmtlib/fmt/pull/2056>
,#2072 <https://github.com/fmtlib/fmt/pull/2072>
,#2075 <https://github.com/fmtlib/fmt/pull/2075>
,#2078 <https://github.com/fmtlib/fmt/issues/2078>
,#2129 <https://github.com/fmtlib/fmt/pull/2129>
,#2326 <https://github.com/fmtlib/fmt/pull/2326>
). For example (godbolt <https://godbolt.org/z/Mxx9d89jM>
__):
.. code:: c++
#include <fmt/compile.h> consteval auto compile_time_itoa(int value) -> std::array<char, 10> { auto result = std::array<char, 10>(); fmt::format_to(result.data(), FMT_COMPILE("{}"), value); return result; } constexpr auto answer = compile_time_itoa(42);
Most of the formatting functionality is available at compile time with a notable exception of floating-point numbers and pointers. Thanks
@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.- โก๏ธ Optimized handling of format specifiers during format string compilation.
For example, hexadecimal formatting (
"{:x}"
) is now 3-7x faster than before when usingformat_to
with format string compilation and a stack-allocated buffer (#1944 <https://github.com/fmtlib/fmt/issues/1944>
_).
Before (7.1.3)::
---------------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------------- FMTCompileOld/0 15.5 ns 15.5 ns 43302898 FMTCompileOld/42 16.6 ns 16.6 ns 43278267 FMTCompileOld/273123 18.7 ns 18.6 ns 37035861 FMTCompileOld/9223372036854775807 19.4 ns 19.4 ns 35243000 ----------------------------------------------------------------------------
After (8.x)::
---------------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------------- FMTCompileNew/0 1.99 ns 1.99 ns 360523686 FMTCompileNew/42 2.33 ns 2.33 ns 279865664 FMTCompileNew/273123 3.72 ns 3.71 ns 190230315 FMTCompileNew/9223372036854775807 5.28 ns 5.26 ns 130711631 ----------------------------------------------------------------------------
It is even faster than
std::to_chars
from libc++ compiled with clang on macOS::---------------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------------- ToChars/0 4.42 ns 4.41 ns 160196630 ToChars/42 5.00 ns 4.98 ns 140735201 ToChars/273123 7.26 ns 7.24 ns 95784130 ToChars/9223372036854775807 8.77 ns 8.75 ns 75872534 ----------------------------------------------------------------------------
In other cases, especially involving
std::string
construction, the speed up is usually lower because handling format specifiers takes a smaller fraction of the total time.- โ Added the
_cf
user-defined literal to represent a compiled format string. It can be used instead of theFMT_COMPILE
macro (#2043 <https://github.com/fmtlib/fmt/pull/2043>
,#2242 <https://github.com/fmtlib/fmt/pull/2242>
):
.. code:: c++
#include <fmt/compile.h> using namespace fmt::literals; auto s = fmt::format(FMT_COMPILE("{}"), 42); // ๐ not modern auto s = fmt::format("{}"_cf, 42); // ๐ modern as hell
It requires compiler support for class types in non-type template parameters (a C++20 feature) which is available in GCC 9.3+. Thanks
@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.- Format string compilation now requires
format
functions offormatter
specializations for user-defined types to beconst
:
.. code:: c++
template <> struct fmt::formatter<my_type>: formatter<string_view> { template <typename FormatContext> auto format(my_type obj, FormatContext& ctx) const { // Note const here. // ... } };
- โ Added UDL-based named argument support to format string compilation
(
#2243 <https://github.com/fmtlib/fmt/pull/2243>
,#2281 <https://github.com/fmtlib/fmt/pull/2281>
). For example:
.. code:: c++
#include <fmt/compile.h> using namespace fmt::literals; auto s = fmt::format(FMT_COMPILE("{answer}"), "answer"_a = 42);
Here the argument named "answer" is resolved at compile time with no runtime overhead. Thanks
@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.โ Added format string compilation support to
fmt::print
(#2280 <https://github.com/fmtlib/fmt/issues/2280>
,#2304 <https://github.com/fmtlib/fmt/pull/2304>
). Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.โ Added initial support for compiling {fmt} as a C++20 module (
#2235 <https://github.com/fmtlib/fmt/pull/2235>
,#2240 <https://github.com/fmtlib/fmt/pull/2240>
,#2260 <https://github.com/fmtlib/fmt/pull/2260>
,#2282 <https://github.com/fmtlib/fmt/pull/2282>
,#2283 <https://github.com/fmtlib/fmt/pull/2283>
,#2288 <https://github.com/fmtlib/fmt/pull/2288>
,#2298 <https://github.com/fmtlib/fmt/pull/2298>
,#2306 <https://github.com/fmtlib/fmt/pull/2306>
,#2307 <https://github.com/fmtlib/fmt/pull/2307>
,#2309 <https://github.com/fmtlib/fmt/pull/2309>
,#2318 <https://github.com/fmtlib/fmt/pull/2318>
,#2324 <https://github.com/fmtlib/fmt/pull/2324>
,#2332 <https://github.com/fmtlib/fmt/pull/2332>
,#2340 <https://github.com/fmtlib/fmt/pull/2340>
). Thanks@DanielaE (Daniela Engert) <https://github.com/DanielaE>
_.0๏ธโฃ Made symbols private by default reducing shared library size (
#2301 <https://github.com/fmtlib/fmt/pull/2301>
). For example there was a ~15% reported reduction on one platform. Thanks@sergiud (Sergiu Deitsch) <https://github.com/sergiud>
.โก๏ธ Optimized includes making the result of preprocessing
fmt/format.h
~20% smaller with libstdc++/C++20 and slightly improving build times (#1998 <https://github.com/fmtlib/fmt/issues/1998>
_).โ Added support of ranges with non-const
begin
/end
(#1953 <https://github.com/fmtlib/fmt/pull/1953>
). Thanks@kitegi (sarah) <https://github.com/kitegi>
.โ Added support of
std::byte
and other formattable types tofmt::join
(#1981 <https://github.com/fmtlib/fmt/issues/1981>
,#2040 <https://github.com/fmtlib/fmt/issues/2040>
,#2050 <https://github.com/fmtlib/fmt/pull/2050>
,#2262 <https://github.com/fmtlib/fmt/issues/2262>
). For example:
.. code:: c++
#include <fmt/format.h> #include <cstddef> #include <vector> int main() { auto bytes = std::vector{std::byte(4), std::byte(2)}; fmt::print("{}", fmt::join(bytes, "")); }
prints "42".
Thanks
@kamibo (Camille Bordignon) <https://github.com/kamibo>
_.- 0๏ธโฃ Implemented the default format for
std::chrono::system_clock
(#2319 <https://github.com/fmtlib/fmt/issues/2319>
,#2345 <https://github.com/fmtlib/fmt/pull/2345>
). For example:
.. code:: c++
#include <fmt/chrono.h> int main() { fmt::print("{}", std::chrono::system_clock::now()); }
prints "2021-06-18 15:22:00" (the output depends on the current date and time). Thanks
@sunmy2019 <https://github.com/sunmy2019>
_.- 0๏ธโฃ Made more chrono specifiers locale independent by default. Use the
'L'
specifier to get localized formatting. For example:
.. code:: c++
#include <fmt/chrono.h> int main() { std::locale::global(std::locale("ru_RU.UTF-8")); auto monday = std::chrono::weekday(1); fmt::print("{}\n", monday); // prints "Mon" fmt::print("{:L}\n", monday); // prints "ะฟะฝ" }
๐ Improved locale handling in chrono formatting (
#2337 <https://github.com/fmtlib/fmt/issues/2337>
,#2349 <https://github.com/fmtlib/fmt/pull/2349>
,#2350 <https://github.com/fmtlib/fmt/pull/2350>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.๐ Deprecated
fmt/locale.h
moving the formatting functions that take a locale tofmt/format.h
(char
) andfmt/xchar
(other overloads). This doesn't introduce a dependency on<locale>
so there is virtually no compile time effect.๐ Deprecated an undocumented
format_to
overload that takesbasic_memory_buffer
.Made parameter order in
vformat_to
consistent withformat_to
(#2327 <https://github.com/fmtlib/fmt/issues/2327>
_).โ Added support for time points with arbitrary durations (
#2208 <https://github.com/fmtlib/fmt/issues/2208>
_). For example:
.. code:: c++
#include <fmt/chrono.h> int main() { using tp = std::chrono::time_point< std::chrono::system_clock, std::chrono::seconds>; fmt::print("{:%S}", tp(std::chrono::seconds(42))); }
prints "42".
- 0๏ธโฃ Formatting floating-point numbers no longer produces trailing zeros by default
for consistency with
std::format
. For example:
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{0:.3}", 1.1); }
prints "1.1". Use the
'#'
specifier to keep trailing zeros.โฌ๏ธ Dropped a limit on the number of elements in a range and replaced
{}
with[]
as range delimiters for consistency with Python'sstr.format
.The
'L'
specifier for locale-specific numeric formatting can now be combined with presentation specifiers as instd::format
. For example:
.. code:: c++
#include <fmt/core.h> #include <locale> int main() { std::locale::global(std::locale("fr_FR.UTF-8")); fmt::print("{0:.2Lf}", 0.42); }
prints "0,42". The deprecated
'n'
specifier has been removed.Made the
0
specifier ignored for infinity and NaN (#2305 <https://github.com/fmtlib/fmt/issues/2305>
,#2310 <https://github.com/fmtlib/fmt/pull/2310>
). Thanks@Liedtke (Matthias Liedtke) <https://github.com/Liedtke>
_.0๏ธโฃ Made the hexfloat formatting use the right alignment by default (
#2308 <https://github.com/fmtlib/fmt/issues/2308>
,#2317 <https://github.com/fmtlib/fmt/pull/2317>
). Thanks@Liedtke (Matthias Liedtke) <https://github.com/Liedtke>
_.โ Removed the deprecated numeric alignment (
'='
). Use the'0'
specifier instead.โ Removed the deprecated
fmt/posix.h
header that has been replaced withfmt/os.h
.Removed the deprecated
format_to_n_context
,format_to_n_args
andmake_format_to_n_args
. They have been replaced withformat_context
,format_args` and
make_format_args`` respectively.๐ Moved
wchar_t
-specific functions and types tofmt/xchar.h
. You can defineFMT_DEPRECATED_INCLUDE_XCHAR
to automatically includefmt/xchar.h
fromfmt/format.h
but this will be disabled in the next major release.๐ Fixed handling of the
'+'
specifier in localized formatting (#2133 <https://github.com/fmtlib/fmt/issues/2133>
_).โ Added support for the
's'
format specifier that gives textual representation ofbool
(#2094 <https://github.com/fmtlib/fmt/issues/2094>
,#2109 <https://github.com/fmtlib/fmt/pull/2109>
). For example:
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{:s}", true); }
prints "true". Thanks
@powercoderlol (Ivan Polyakov) <https://github.com/powercoderlol>
_.- Made
fmt::ptr
work with function pointers (#2131 <https://github.com/fmtlib/fmt/pull/2131>
_). For example:
.. code:: c++
#include <fmt/format.h> int main() { fmt::print("My main: {}\n", fmt::ptr(main)); }
Thanks
@mikecrowe (Mike Crowe) <https://github.com/mikecrowe>
_.๐ The undocumented support for specializing
formatter
for pointer types has been removed.๐ Fixed
fmt::formatted_size
with format string compilation (#2141 <https://github.com/fmtlib/fmt/pull/2141>
,#2161 <https://github.com/fmtlib/fmt/pull/2161>
). Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.๐ Fixed handling of empty format strings during format string compilation (
#2042 <https://github.com/fmtlib/fmt/issues/2042>
_):
.. code:: c++
auto s = fmt::format(FMT_COMPILE(""));
Thanks
@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.๐ Fixed handling of enums in
fmt::to_string
(#2036 <https://github.com/fmtlib/fmt/issues/2036>
_).๐ Improved width computation (
#2033 <https://github.com/fmtlib/fmt/issues/2033>
,#2091 <https://github.com/fmtlib/fmt/issues/2091>
). For example:
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{:-<10}{}\n", "ไฝ ๅฅฝ", "ไธ็"); fmt::print("{:-<10}{}\n", "hello", "world"); }
prints
.. image:: https://user-images.githubusercontent.com/576385/ 119840373-cea3ca80-beb9-11eb-91e0-54266c48e181.png
on a modern terminal.
- The experimental fast output stream (
fmt::ostream
) is now truncated by default for consistency withfopen
(#2018 <https://github.com/fmtlib/fmt/issues/2018>
_). For example:
.. code:: c++
#include <fmt/os.h> int main() { fmt::ostream out1 = fmt::output_file("guide"); out1.print("Zaphod"); out1.close(); fmt::ostream out2 = fmt::output_file("guide"); out2.print("Ford"); }
writes "Ford" to the file "guide". To preserve the old file content if any pass
fmt::file::WRONLY | fmt::file::CREATE
flags tofmt::output_file
.๐ Fixed moving of
fmt::ostream
that holds buffered data (#2197 <https://github.com/fmtlib/fmt/issues/2197>
,#2198 <https://github.com/fmtlib/fmt/pull/2198>
). Thanks@vtta <https://github.com/vtta>
_.๐ป Replaced the
fmt::system_error
exception with a function of the same name that constructsstd::system_error
(#2266 <https://github.com/fmtlib/fmt/issues/2266>
_).๐ Replaced the
fmt::windows_error
exception with a function of the same name that constructsstd::system_error
with the category returned byfmt::system_category()
(#2274 <https://github.com/fmtlib/fmt/issues/2274>
,#2275 <https://github.com/fmtlib/fmt/pull/2275>
). The latter is similar tostd::sytem_category
but correctly handles UTF-8. Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.Replaced
fmt::error_code
withstd::error_code
and made it formattable (#2269 <https://github.com/fmtlib/fmt/issues/2269>
,#2270 <https://github.com/fmtlib/fmt/pull/2270>
,#2273 <https://github.com/fmtlib/fmt/pull/2273>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.โ Added speech synthesis support (
#2206 <https://github.com/fmtlib/fmt/pull/2206>
_).Made
format_to
work with a memory buffer that has a custom allocator (#2300 <https://github.com/fmtlib/fmt/pull/2300>
). Thanks@voxmea <https://github.com/voxmea>
.๐ Added
Allocator::max_size
support tobasic_memory_buffer
. (#1960 <https://github.com/fmtlib/fmt/pull/1960>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
.โ Added wide string support to
fmt::join
(#2236 <https://github.com/fmtlib/fmt/pull/2236>
). Thanks@crbrz <https://github.com/crbrz>
.Made iterators passed to
formatter
specializations via a format context satisfy C++20std::output_iterator
requirements (#2156 <https://github.com/fmtlib/fmt/issues/2156>
,#2158 <https://github.com/fmtlib/fmt/pull/2158>
,#2195 <https://github.com/fmtlib/fmt/issues/2195>
,#2204 <https://github.com/fmtlib/fmt/pull/2204>
). Thanks@randomnetcat (Jason Cobb) <https://github.com/randomnetcat>
_.โก๏ธ Optimized the
printf
implementation (#1982 <https://github.com/fmtlib/fmt/pull/1982>
,#1984 <https://github.com/fmtlib/fmt/pull/1984>
,#2016 <https://github.com/fmtlib/fmt/pull/2016>
,#2164 <https://github.com/fmtlib/fmt/pull/2164>
). Thanks@rimathia <https://github.com/rimathia>
_ and@moiwi <https://github.com/moiwi>
_.๐ Improved detection of
constexpr
char_traits
(#2246 <https://github.com/fmtlib/fmt/pull/2246>
,#2257 <https://github.com/fmtlib/fmt/pull/2257>
). Thanks@phprus (Vladislav Shchapov) <https://github.com/phprus>
_.๐ Fixed writing to
stdout
when it is redirected toNUL
on Windows (#2080 <https://github.com/fmtlib/fmt/issues/2080>
_).๐ Fixed exception propagation from iterators (
#2097 <https://github.com/fmtlib/fmt/issues/2097>
_).๐ Improved
strftime
error handling (#2238 <https://github.com/fmtlib/fmt/issues/2238>
,#2244 <https://github.com/fmtlib/fmt/pull/2244>
). Thanks@yumeyao <https://github.com/yumeyao>
_.๐ Stopped using deprecated GCC UDL template extension.
โ Added
fmt/args.h
to the install target (#2096 <https://github.com/fmtlib/fmt/issues/2096>
_).Error messages are now passed to assert when exceptions are disabled (
#2145 <https://github.com/fmtlib/fmt/pull/2145>
). Thanks@NobodyXu (Jiahao XU) <https://github.com/NobodyXu>
.Added the
FMT_MASTER_PROJECT
CMake option to control build and install targets when {fmt} is included viaadd_subdirectory
(#2098 <https://github.com/fmtlib/fmt/issues/2098>
,#2100 <https://github.com/fmtlib/fmt/pull/2100>
). Thanks@randomizedthinking <https://github.com/randomizedthinking>
_.๐ Improved build configuration (
#2026 <https://github.com/fmtlib/fmt/pull/2026>
,#2122 <https://github.com/fmtlib/fmt/pull/2122>
). Thanks@luncliff (Park DongHa) <https://github.com/luncliff>
_ and@ibaned (Dan Ibanez) <https://github.com/ibaned>
_.๐ Fixed various warnings and compilation issues (
#1947 <https://github.com/fmtlib/fmt/issues/1947>
,#1959 <https://github.com/fmtlib/fmt/pull/1959>
,#1963 <https://github.com/fmtlib/fmt/pull/1963>
,#1965 <https://github.com/fmtlib/fmt/pull/1965>
,#1966 <https://github.com/fmtlib/fmt/issues/1966>
,#1974 <https://github.com/fmtlib/fmt/pull/1974>
,#1975 <https://github.com/fmtlib/fmt/pull/1975>
,#1990 <https://github.com/fmtlib/fmt/pull/1990>
,#2000 <https://github.com/fmtlib/fmt/issues/2000>
,#2001 <https://github.com/fmtlib/fmt/pull/2001>
,#2002 <https://github.com/fmtlib/fmt/issues/2002>
,#2004 <https://github.com/fmtlib/fmt/issues/2004>
,#2006 <https://github.com/fmtlib/fmt/pull/2006>
,#2009 <https://github.com/fmtlib/fmt/pull/2009>
,#2010 <https://github.com/fmtlib/fmt/pull/2010>
,#2038 <https://github.com/fmtlib/fmt/issues/2038>
,#2039 <https://github.com/fmtlib/fmt/issues/2039>
,#2047 <https://github.com/fmtlib/fmt/issues/2047>
,#2053 <https://github.com/fmtlib/fmt/pull/2053>
,#2059 <https://github.com/fmtlib/fmt/issues/2059>
,#2065 <https://github.com/fmtlib/fmt/pull/2065>
,#2067 <https://github.com/fmtlib/fmt/pull/2067>
,#2068 <https://github.com/fmtlib/fmt/pull/2068>
,#2073 <https://github.com/fmtlib/fmt/pull/2073>
,#2103 <https://github.com/fmtlib/fmt/issues/2103>
,#2105 <https://github.com/fmtlib/fmt/issues/2105>
,#2106 <https://github.com/fmtlib/fmt/pull/2106>
,#2107 <https://github.com/fmtlib/fmt/pull/2107>
,#2116 <https://github.com/fmtlib/fmt/issues/2116>
,#2117 <https://github.com/fmtlib/fmt/pull/2117>
,#2118 <https://github.com/fmtlib/fmt/issues/2118>
,#2119 <https://github.com/fmtlib/fmt/pull/2119>
,#2127 <https://github.com/fmtlib/fmt/issues/2127>
,#2128 <https://github.com/fmtlib/fmt/pull/2128>
,#2140 <https://github.com/fmtlib/fmt/issues/2140>
,#2142 <https://github.com/fmtlib/fmt/issues/2142>
,#2143 <https://github.com/fmtlib/fmt/pull/2143>
,#2144 <https://github.com/fmtlib/fmt/pull/2144>
,#2147 <https://github.com/fmtlib/fmt/issues/2147>
,#2148 <https://github.com/fmtlib/fmt/issues/2148>
,#2149 <https://github.com/fmtlib/fmt/issues/2149>
,#2152 <https://github.com/fmtlib/fmt/pull/2152>
,#2160 <https://github.com/fmtlib/fmt/pull/2160>
,#2170 <https://github.com/fmtlib/fmt/issues/2170>
,#2175 <https://github.com/fmtlib/fmt/issues/2175>
,#2176 <https://github.com/fmtlib/fmt/issues/2176>
,#2177 <https://github.com/fmtlib/fmt/pull/2177>
,#2178 <https://github.com/fmtlib/fmt/issues/2178>
,#2179 <https://github.com/fmtlib/fmt/pull/2179>
,#2180 <https://github.com/fmtlib/fmt/issues/2180>
,#2181 <https://github.com/fmtlib/fmt/issues/2181>
,#2183 <https://github.com/fmtlib/fmt/pull/2183>
,#2184 <https://github.com/fmtlib/fmt/issues/2184>
,#2185 <https://github.com/fmtlib/fmt/issues/2185>
,#2186 <https://github.com/fmtlib/fmt/pull/2186>
,#2187 <https://github.com/fmtlib/fmt/pull/2187>
,#2190 <https://github.com/fmtlib/fmt/pull/2190>
,#2192 <https://github.com/fmtlib/fmt/pull/2192>
,#2194 <https://github.com/fmtlib/fmt/pull/2194>
,#2205 <https://github.com/fmtlib/fmt/pull/2205>
,#2210 <https://github.com/fmtlib/fmt/issues/2210>
,#2211 <https://github.com/fmtlib/fmt/pull/2211>
,#2215 <https://github.com/fmtlib/fmt/pull/2215>
,#2216 <https://github.com/fmtlib/fmt/pull/2216>
,#2218 <https://github.com/fmtlib/fmt/pull/2218>
,#2220 <https://github.com/fmtlib/fmt/pull/2220>
,#2228 <https://github.com/fmtlib/fmt/issues/2228>
,#2229 <https://github.com/fmtlib/fmt/pull/2229>
,#2230 <https://github.com/fmtlib/fmt/pull/2230>
,#2233 <https://github.com/fmtlib/fmt/issues/2233>
,#2239 <https://github.com/fmtlib/fmt/pull/2239>
,#2248 <https://github.com/fmtlib/fmt/issues/2248>
,#2252 <https://github.com/fmtlib/fmt/issues/2252>
,#2253 <https://github.com/fmtlib/fmt/pull/2253>
,#2255 <https://github.com/fmtlib/fmt/pull/2255>
,#2261 <https://github.com/fmtlib/fmt/issues/2261>
,#2278 <https://github.com/fmtlib/fmt/issues/2278>
,#2284 <https://github.com/fmtlib/fmt/issues/2284>
,#2287 <https://github.com/fmtlib/fmt/pull/2287>
,#2289 <https://github.com/fmtlib/fmt/pull/2289>
,#2290 <https://github.com/fmtlib/fmt/pull/2290>
,#2293 <https://github.com/fmtlib/fmt/pull/2293>
,#2295 <https://github.com/fmtlib/fmt/issues/2295>
,#2296 <https://github.com/fmtlib/fmt/pull/2296>
,#2297 <https://github.com/fmtlib/fmt/pull/2297>
,#2311 <https://github.com/fmtlib/fmt/issues/2311>
,#2313 <https://github.com/fmtlib/fmt/pull/2313>
,#2315 <https://github.com/fmtlib/fmt/pull/2315>
,#2320 <https://github.com/fmtlib/fmt/issues/2320>
,#2321 <https://github.com/fmtlib/fmt/pull/2321>
,#2323 <https://github.com/fmtlib/fmt/pull/2323>
,#2328 <https://github.com/fmtlib/fmt/issues/2328>
,#2329 <https://github.com/fmtlib/fmt/pull/2329>
,#2333 <https://github.com/fmtlib/fmt/pull/2333>
,#2338 <https://github.com/fmtlib/fmt/pull/2338>
,#2341 <https://github.com/fmtlib/fmt/pull/2341>
). Thanks@darklukee <https://github.com/darklukee>
,@fagg (Ashton Fagg) <https://github.com/fagg>
,@killerbot242 (Lieven de Cock) <https://github.com/killerbot242>
,@jgopel (Jonathan Gopel) <https://github.com/jgopel>
,@yeswalrus (Walter Gray) <https://github.com/yeswalrus>
,@Finkman <https://github.com/Finkman>
,@HazardyKnusperkeks (Bjรถrn Schรคpers) <https://github.com/HazardyKnusperkeks>
,@dkavolis (Daumantas Kavolis) <https://github.com/dkavolis>
,@concatime (Issam Maghni) <https://github.com/concatime>
,@chronoxor (Ivan Shynkarenka) <https://github.com/chronoxor>
,@summivox (Yin Zhong) <https://github.com/summivox>
,@yNeo <https://github.com/yNeo>
,@Apache-HB (Elliot) <https://github.com/Apache-HB>
,@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
,@toojays (John Steele Scott) <https://github.com/toojays>
,@Brainy0207 <https://github.com/Brainy0207>
,@vadz (VZ) <https://github.com/vadz>
,@imsherlock (Ryan Sherlock) <https://github.com/imsherlock>
,@phprus (Vladislav Shchapov) <https://github.com/phprus>
,@white238 (Chris White) <https://github.com/white238>
,@yafshar (Yaser Afshar) <https://github.com/yafshar>
,@BillyDonahue (Billy Donahue) <https://github.com/BillyDonahue>
,@jstaahl <https://github.com/jstaahl>
,@denchat <https://github.com/denchat>
,@DanielaE (Daniela Engert) <https://github.com/DanielaE>
,@ilyakurdyukov (Ilya Kurdyukov) <https://github.com/ilyakurdyukov>
,@ilmai <https://github.com/ilmai>
,@JessyDL (Jessy De Lannoit) <https://github.com/JessyDL>
,@sergiud (Sergiu Deitsch) <https://github.com/sergiud>
,@mwinterb <https://github.com/mwinterb>
,@sven-herrmann <https://github.com/sven-herrmann>
,@jmelas (John Melas) <https://github.com/jmelas>
,@twoixter (Jose Miguel Pรฉrez) <https://github.com/twoixter>
,@crbrz <https://github.com/crbrz>
,@upsj (Tobias Ribizel) <https://github.com/upsj>
_.๐ Improved documentation (
#1986 <https://github.com/fmtlib/fmt/issues/1986>
,#2051 <https://github.com/fmtlib/fmt/pull/2051>
,#2057 <https://github.com/fmtlib/fmt/issues/2057>
,#2081 <https://github.com/fmtlib/fmt/pull/2081>
,#2084 <https://github.com/fmtlib/fmt/issues/2084>
,#2312 <https://github.com/fmtlib/fmt/pull/2312>
). Thanks@imba-tjd (่ฐญไน้ผ) <https://github.com/imba-tjd>
,@0x416c69 (AlฮนAััaััฮนN) <https://github.com/0x416c69>
,@mordante <https://github.com/mordante>
_.โ Continuous integration and test improvements (
#1969 <https://github.com/fmtlib/fmt/issues/1969>
,#1991 <https://github.com/fmtlib/fmt/pull/1991>
,#2020 <https://github.com/fmtlib/fmt/pull/2020>
,#2110 <https://github.com/fmtlib/fmt/pull/2110>
,#2114 <https://github.com/fmtlib/fmt/pull/2114>
,#2196 <https://github.com/fmtlib/fmt/issues/2196>
,#2217 <https://github.com/fmtlib/fmt/pull/2217>
,#2247 <https://github.com/fmtlib/fmt/pull/2247>
,#2256 <https://github.com/fmtlib/fmt/pull/2256>
,#2336 <https://github.com/fmtlib/fmt/pull/2336>
,#2346 <https://github.com/fmtlib/fmt/pull/2346>
). Thanks@jgopel (Jonathan Gopel) <https://github.com/jgopel>
,@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_ and@DanielaE (Daniela Engert) <https://github.com/DanielaE>
_.
- 0๏ธโฃ Enabled compile-time format string checks by default.
For example (
-
v7.1.3 Changes
November 25, 2020Fixed handling of buffer boundaries in
format_to_n
(#1996 <https://github.com/fmtlib/fmt/issues/1996>
,#2029 <https://github.com/fmtlib/fmt/issues/2029>
).๐ Fixed linkage errors when linking with a shared library (
#2011 <https://github.com/fmtlib/fmt/issues/2011>
_).๐ Reintroduced ostream support to range formatters (
#2014 <https://github.com/fmtlib/fmt/issues/2014>
_).Worked around an issue with mixing std versions in gcc (
#2017 <https://github.com/fmtlib/fmt/issues/2017>
_).
-
v7.1.2 Changes
November 04, 2020- ๐ Fixed floating point formatting with large precision
(
#1976 <https://github.com/fmtlib/fmt/issues/1976>
_).
- ๐ Fixed floating point formatting with large precision
(
-
v7.1.1 Changes
November 02, 2020๐ Fixed ABI compatibility with 7.0.x (
#1961 <https://github.com/fmtlib/fmt/issues/1961>
_).Added the
FMT_ARM_ABI_COMPATIBILITY
macro to work around ABI incompatibility between GCC and Clang on ARM (#1919 <https://github.com/fmtlib/fmt/issues/1919>
_).Worked around a SFINAE bug in GCC 8 (
#1957 <https://github.com/fmtlib/fmt/issues/1957>
_).๐ Fixed linkage errors when building with GCC's LTO (
#1955 <https://github.com/fmtlib/fmt/issues/1955>
_).Fixed a compilation error when building without
__builtin_clz
or equivalent (#1968 <https://github.com/fmtlib/fmt/pull/1968>
). Thanks@tohammer (Tobias Hammer) <https://github.com/tohammer>
.๐ Fixed a sign conversion warning (
#1964 <https://github.com/fmtlib/fmt/pull/1964>
). Thanks@OptoCloud <https://github.com/OptoCloud>
.
-
v7.1.0 Changes
October 26, 2020- Switched from
Grisu3 <https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf>
_ toDragonbox <https://github.com/jk-jeon/dragonbox>
_ for the default floating-point formatting which gives the shortest decimal representation with round-trip guarantee and correct rounding (#1882 <https://github.com/fmtlib/fmt/pull/1882>
,#1887 <https://github.com/fmtlib/fmt/pull/1887>
,#1894 <https://github.com/fmtlib/fmt/pull/1894>
). This makes {fmt} up to 20-30x faster than common implementations ofstd::ostringstream
andsprintf
ondtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>
and faster than double-conversion and Ryลซ:
.. image:: https://user-images.githubusercontent.com/576385/ 95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png
It is possible to get even better performance at the cost of larger binary size by compiling with the
FMT_USE_FULL_CACHE_DRAGONBOX
macro set to 1.Thanks
@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
_.- โ Added an experimental unsynchronized file output API which, together with
format string compilation <https://fmt.dev/latest/api.html#compile-api>
, can give5-9 times speed up compared to fprintf <https://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html>
on common platforms (godbolt <https://godbolt.org/z/nsTcG8>
__):
.. code:: c++
#include <fmt/os.h> int main() { auto f = fmt::output_file("guide"); f.print("The answer is {}.", 42); }
- Added a formatter for
std::chrono::time_point<system_clock>
(#1819 <https://github.com/fmtlib/fmt/issues/1819>
,#1837 <https://github.com/fmtlib/fmt/pull/1837>
). For example (godbolt <https://godbolt.org/z/c4M6fh>
__):
.. code:: c++
#include <fmt/chrono.h> int main() { auto now = std::chrono::system_clock::now(); fmt::print("The time is {:%H:%M:%S}.\n", now); }
Thanks
@adamburgess (Adam Burgess) <https://github.com/adamburgess>
_.- โ Added support for ranges with non-const
begin
/end
tofmt::join
(#1784 <https://github.com/fmtlib/fmt/issues/1784>
,#1786 <https://github.com/fmtlib/fmt/pull/1786>
). For example (godbolt <https://godbolt.org/z/jP63Tv>
__):
.. code:: c++
#include <fmt/ranges.h> #include <range/v3/view/filter.hpp> int main() { using std::literals::string_literals::operator""s; auto strs = std::array{"a"s, "bb"s, "ccc"s}; auto range = strs | ranges::views::filter( [] (const std::string &x) { return x.size() != 2; } ); fmt::print("{}\n", fmt::join(range, "")); }
prints "accc".
Thanks
@tonyelewis (Tony E Lewis) <https://github.com/tonyelewis>
_.โ Added a
memory_buffer::append
overload that takes a range (#1806 <https://github.com/fmtlib/fmt/pull/1806>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
.๐ Improved handling of single code units in
FMT_COMPILE
. For example:
.. code:: c++
#include <fmt/compile.h> char* f(char* buf) { return fmt::format_to(buf, FMT_COMPILE("x{}"), 42); }
compiles to just (
godbolt <https://godbolt.org/z/5vncz3>
__):.. code:: asm
_Z1fPc: movb $120, (%rdi) xorl %edx, %edx cmpl $42, _ZN3fmt2v76detail10basic_dataIvE23zero_or_powers_of_10_32E+8(%rip) movl $3, %eax seta %dl subl %edx, %eax movzwl _ZN3fmt2v76detail10basic_dataIvE6digitsE+84(%rip), %edx cltq addq %rdi, %rax movw %dx, -2(%rax) ret
Here a single
mov
instruction writes'x'
($120
) to the output buffer.โ Added dynamic width support to format string compilation (
#1809 <https://github.com/fmtlib/fmt/issues/1809>
_).๐ Improved error reporting for unformattable types: now you'll get the type name directly in the error message instead of the note:
.. code:: c++
#include <fmt/core.h> struct how_about_no {}; int main() { fmt::print("{}", how_about_no()); }
Error (
godbolt <https://godbolt.org/z/GoxM4e>
__):fmt/core.h:1438:3: error: static_assert failed due to requirement 'fmt::v7::formattable<how_about_no>()' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt" ...
- Added the
make_args_checked <https://fmt.dev/7.1.0/api.html#argument-lists>
_ function template that allows you to write formatting functions with compile-time format string checks and avoid binary code bloat (godbolt <https://godbolt.org/z/PEf9qr>
__):
.. code:: c++
void vlog(const char* file, int line, fmt::string_view format, fmt::format_args args) { fmt::print("{}: {}: ", file, line); fmt::vprint(format, args); } template <typename S, typename... Args> void log(const char* file, int line, const S& format, Args&&... args) { vlog(file, line, format, fmt::make_args_checked<Args...>(format, args...)); } #define MY_LOG(format, ...) \ log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__) MY_LOG("invalid squishiness: {}", 42);
- ๐จ Replaced
snprintf
fallback with a faster internal IEEE 754float
anddouble
formatter for arbitrary precision. For example (godbolt <https://godbolt.org/z/dPhWvj>
__):
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{:.500}\n", 4.9406564584124654E-324); }
prints
4.9406564584124654417656879286822137236505980261432476442558568250067550727020875186529983636163599237979656469544571773092665671035593979639877479601078187812630071319031140452784581716784898210368871863605699873072305000638740915356498438731247339727316961514003171538539807412623856559117102665855668676818703956031062493194527159149245532930545654440112748012970999954193198940908041656332452475714786901472678015935523861155013480352649347201937902681071074917033322268447533357208324319360923829e-324
.- Made
format_to_n
andformatted_size
part of thecore API <https://fmt.dev/latest/api.html#core-api>
__ (godbolt <https://godbolt.org/z/sPjY1K>
__):
.. code:: c++
#include <fmt/core.h> int main() { char buffer[10]; auto result = fmt::format_to_n(buffer, sizeof(buffer), "{}", 42); }
- Added
fmt::format_to_n
overload with format string compilation (#1764 <https://github.com/fmtlib/fmt/issues/1764>
,#1767 <https://github.com/fmtlib/fmt/pull/1767>
,#1869 <https://github.com/fmtlib/fmt/pull/1869>
). For example (godbolt <https://godbolt.org/z/93h86q>
_):
.. code:: c++
#include <fmt/compile.h> int main() { char buffer[8]; fmt::format_to_n(buffer, sizeof(buffer), FMT_COMPILE("{}"), 42); }
Thanks
@Kurkin (Dmitry Kurkin) <https://github.com/Kurkin>
,@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
.- Added
fmt::format_to
overload that taketext_style
(#1593 <https://github.com/fmtlib/fmt/issues/1593>
,#1842 <https://github.com/fmtlib/fmt/issues/1842>
,#1843 <https://github.com/fmtlib/fmt/pull/1843>
). For example (godbolt <https://godbolt.org/z/91153r>
_):
.. code:: c++
#include <fmt/color.h> int main() { std::string out; fmt::format_to(std::back_inserter(out), fmt::emphasis::bold | fg(fmt::color::red), "The answer is {}.", 42); }
Thanks
@Naios (Denis Blank) <https://github.com/Naios>
_.- Made the
'#'
specifier emit trailing zeros in addition to the decimal point (#1797 <https://github.com/fmtlib/fmt/issues/1797>
). For example (godbolt <https://godbolt.org/z/bhdcW9>
_):
.. code:: c++
#include <fmt/core.h> int main() { fmt::print("{:#.2g}", 0.5); }
prints
0.50
.๐ Changed the default floating point format to not include
.0
for consistency withstd::format
andstd::to_chars
(#1893 <https://github.com/fmtlib/fmt/issues/1893>
,#1943 <https://github.com/fmtlib/fmt/issues/1943>
). It is possible to get the decimal point and trailing zero with the#
specifier.๐ Fixed an issue with floating-point formatting that could result in addition of a non-significant trailing zero in rare cases e.g.
1.00e-34
instead of1.0e-34
(#1873 <https://github.com/fmtlib/fmt/issues/1873>
,#1917 <https://github.com/fmtlib/fmt/issues/1917>
).Made
fmt::to_string
fallback onostream
insertion operator if theformatter
specialization is not provided (#1815 <https://github.com/fmtlib/fmt/issues/1815>
,#1829 <https://github.com/fmtlib/fmt/pull/1829>
). Thanks@alexezeder (Alexey Ochapov) <https://github.com/alexezeder>
_.โ Added support for the append mode to the experimental file API and improved
fcntl.h
detection. (#1847 <https://github.com/fmtlib/fmt/pull/1847>
,#1848 <https://github.com/fmtlib/fmt/pull/1848>
). Thanks@t-wiser <https://github.com/t-wiser>
_.๐ Fixed handling of types that have both an implicit conversion operator and an overloaded
ostream
insertion operator (#1766 <https://github.com/fmtlib/fmt/issues/1766>
_).๐ Fixed a slicing issue in an internal iterator type (
#1822 <https://github.com/fmtlib/fmt/pull/1822>
). Thanks@BRevzin (Barry Revzin) <https://github.com/BRevzin>
.๐ Fixed an issue in locale-specific integer formatting (
#1927 <https://github.com/fmtlib/fmt/issues/1927>
_).๐ Fixed handling of exotic code unit types (
#1870 <https://github.com/fmtlib/fmt/issues/1870>
,#1932 <https://github.com/fmtlib/fmt/issues/1932>
).Improved
FMT_ALWAYS_INLINE
(#1878 <https://github.com/fmtlib/fmt/pull/1878>
). Thanks@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
.โ Removed dependency on
windows.h
(#1900 <https://github.com/fmtlib/fmt/pull/1900>
). Thanks@bernd5 (Bernd Baumanns) <https://github.com/bernd5>
.โก๏ธ Optimized counting of decimal digits on MSVC (
#1890 <https://github.com/fmtlib/fmt/pull/1890>
). Thanks@mwinterb <https://github.com/mwinterb>
.๐ Improved documentation (
#1772 <https://github.com/fmtlib/fmt/issues/1772>
,#1775 <https://github.com/fmtlib/fmt/pull/1775>
,#1792 <https://github.com/fmtlib/fmt/pull/1792>
,#1838 <https://github.com/fmtlib/fmt/pull/1838>
,#1888 <https://github.com/fmtlib/fmt/pull/1888>
,#1918 <https://github.com/fmtlib/fmt/pull/1918>
,#1939 <https://github.com/fmtlib/fmt/pull/1939>
). Thanks@leolchat (Lรฉonard Gรฉrard) <https://github.com/leolchat>
,@pepsiman (Malcolm Parsons) <https://github.com/pepsiman>
,@Klaim (Joรซl Lamotte) <https://github.com/Klaim>
,@ravijanjam (Ravi J) <https://github.com/ravijanjam>
,@francesco-st <https://github.com/francesco-st>
,@udnaan (Adnan) <https://github.com/udnaan>
_.โฌ๏ธ Added the
FMT_REDUCE_INT_INSTANTIATIONS
CMake option that reduces the binary code size at the cost of some integer formatting performance. This can be useful for extremely memory-constrained embedded systems (#1778 <https://github.com/fmtlib/fmt/issues/1778>
,#1781 <https://github.com/fmtlib/fmt/pull/1781>
). Thanks@kammce (Khalil Estell) <https://github.com/kammce>
_.๐ Added the
FMT_USE_INLINE_NAMESPACES
macro to control usage of inline namespaces (#1945 <https://github.com/fmtlib/fmt/pull/1945>
). Thanks@darklukee <https://github.com/darklukee>
.๐ Improved build configuration (
#1760 <https://github.com/fmtlib/fmt/pull/1760>
,#1770 <https://github.com/fmtlib/fmt/pull/1770>
,#1779 <https://github.com/fmtlib/fmt/issues/1779>
,#1783 <https://github.com/fmtlib/fmt/pull/1783>
,#1823 <https://github.com/fmtlib/fmt/pull/1823>
). Thanks@dvetutnev (Dmitriy Vetutnev) <https://github.com/dvetutnev>
,@xvitaly (Vitaly Zaitsev) <https://github.com/xvitaly>
,@tambry (Raul Tambre) <https://github.com/tambry>
,@medithe <https://github.com/medithe>
,@martinwuehrer (Martin Wรผhrer) <https://github.com/martinwuehrer>
.๐ Fixed various warnings and compilation issues (
#1790 <https://github.com/fmtlib/fmt/pull/1790>
,#1802 <https://github.com/fmtlib/fmt/pull/1802>
,#1808 <https://github.com/fmtlib/fmt/pull/1808>
,#1810 <https://github.com/fmtlib/fmt/issues/1810>
,#1811 <https://github.com/fmtlib/fmt/issues/1811>
,#1812 <https://github.com/fmtlib/fmt/pull/1812>
,#1814 <https://github.com/fmtlib/fmt/pull/1814>
,#1816 <https://github.com/fmtlib/fmt/pull/1816>
,#1817 <https://github.com/fmtlib/fmt/pull/1817>
,#1818 <https://github.com/fmtlib/fmt/pull/1818>
,#1825 <https://github.com/fmtlib/fmt/issues/1825>
,#1836 <https://github.com/fmtlib/fmt/pull/1836>
,#1855 <https://github.com/fmtlib/fmt/pull/1855>
,#1856 <https://github.com/fmtlib/fmt/pull/1856>
,#1860 <https://github.com/fmtlib/fmt/pull/1860>
,#1877 <https://github.com/fmtlib/fmt/pull/1877>
,#1879 <https://github.com/fmtlib/fmt/pull/1879>
,#1880 <https://github.com/fmtlib/fmt/pull/1880>
,#1896 <https://github.com/fmtlib/fmt/issues/1896>
,#1897 <https://github.com/fmtlib/fmt/pull/1897>
,#1898 <https://github.com/fmtlib/fmt/pull/1898>
,#1904 <https://github.com/fmtlib/fmt/issues/1904>
,#1908 <https://github.com/fmtlib/fmt/pull/1908>
,#1911 <https://github.com/fmtlib/fmt/issues/1911>
,#1912 <https://github.com/fmtlib/fmt/issues/1912>
,#1928 <https://github.com/fmtlib/fmt/issues/1928>
,#1929 <https://github.com/fmtlib/fmt/pull/1929>
,#1935 <https://github.com/fmtlib/fmt/issues/1935>
,#1937 <https://github.com/fmtlib/fmt/pull/1937>
,#1942 <https://github.com/fmtlib/fmt/pull/1942>
,#1949 <https://github.com/fmtlib/fmt/issues/1949>
). Thanks@TheQwertiest <https://github.com/TheQwertiest>
,@medithe <https://github.com/medithe>
,@martinwuehrer (Martin Wรผhrer) <https://github.com/martinwuehrer>
,@n16h7hunt3r <https://github.com/n16h7hunt3r>
,@Othereum (Seokjin Lee) <https://github.com/Othereum>
,@gsjaardema (Greg Sjaardema) <https://github.com/gsjaardema>
,@AlexanderLanin (Alexander Lanin) <https://github.com/AlexanderLanin>
,@gcerretani (Giovanni Cerretani) <https://github.com/gcerretani>
,@chronoxor (Ivan Shynkarenka) <https://github.com/chronoxor>
,@noizefloor (Jan Schwers) <https://github.com/noizefloor>
,@akohlmey (Axel Kohlmeyer) <https://github.com/akohlmey>
,@jk-jeon (Junekey Jeon) <https://github.com/jk-jeon>
,@rimathia <https://github.com/rimathia>
,@rglarix (Riccardo Ghetta (larix)) <https://github.com/rglarix>
,@moiwi <https://github.com/moiwi>
,@heckad (Kazantcev Andrey) <https://github.com/heckad>
,@MarcDirven <https://github.com/MarcDirven>
.@BartSiwek (Bart Siwek) <https://github.com/BartSiwek>
,@darklukee <https://github.com/darklukee>
.
- Switched from