Skip to content

Latest commit

 

History

History
2628 lines (2111 loc) · 93.9 KB

ChangeLog.md

File metadata and controls

2628 lines (2111 loc) · 93.9 KB

11.0.2 - 2024-07-20

  • Fixed compatibility with non-POSIX systems (fmtlib#4054, fmtlib#4060).

  • Fixed performance regressions when using std::back_insert_iterator with fmt::format_to (fmtlib#4070).

  • Fixed handling of std::generator and move-only iterators (fmtlib#4053, fmtlib#4057). Thanks @Arghnews.

  • Made formatter<std::string_view>::parse work with types convertible to std::string_view (fmtlib#4036, fmtlib#4055). Thanks @Arghnews.

  • Made volatile void* formattable (fmtlib#4049, fmtlib#4056). Thanks @Arghnews.

  • Made Glib::ustring not be confused with std::string (fmtlib#4052).

  • Made fmt::context iterator compatible with STL algorithms that rely on iterator category (fmtlib#4079).

11.0.1 - 2024-07-05

  • Fixed version number in the inline namespace (fmtlib#4047).

  • Fixed disabling Unicode support via CMake (fmtlib#4051).

  • Fixed deprecated visit_format_arg (fmtlib#4043). Thanks @nebkat.

  • Fixed handling of a sign and improved the std::complex formater (fmtlib#4034, fmtlib#4050). Thanks @tesch1 and @phprus.

  • Fixed ADL issues in fmt::printf when using C++20 (fmtlib#4042). Thanks @toge.

  • Removed a redundant check in the formatter for std::expected (fmtlib#4040). Thanks @phprus.

11.0.0 - 2024-07-01

  • Added fmt/base.h which provides a subset of the API with minimal include dependencies and enough functionality to replace all uses of the printf family of functions. This brings the compile time of code using {fmt} much closer to the equivalent printf code as shown on the following benchmark that compiles 100 source files:

    Method Compile Time (s)
    printf 1.6
    IOStreams 25.9
    fmt 10.x 19.0
    fmt 11.0 4.8
    tinyformat 29.1
    Boost Format 55.0

    This gives almost 4x improvement in build speed compared to version 10. Note that the benchmark is purely formatting code and includes. In real projects the difference from printf will be smaller partly because common standard headers will be included in almost any translation unit (TU) anyway. In particular, in every case except printf above ~1s is spent in total on including <type_traits> in all TUs.

  • Optimized includes in other headers such as fmt/format.h which is now roughly equivalent to the old fmt/core.h in terms of build speed.

  • Migrated the documentation at https://fmt.dev/ from Sphinx to MkDocs.

  • Improved C++20 module support (fmtlib#3990, fmtlib#3991, fmtlib#3993, fmtlib#3994, fmtlib#3997, fmtlib#3998, fmtlib#4004, fmtlib#4005, fmtlib#4006, fmtlib#4013, fmtlib#4027, fmtlib#4029). In particular, native CMake support for modules is now used if available. Thanks @yujincheng08 and @matt77hias.

  • Added an option to replace standard includes with import std enabled via the FMT_IMPORT_STD macro (fmtlib#3921, fmtlib#3928). Thanks @matt77hias.

  • Exported fmt::range_format, fmt::range_format_kind and fmt::compiled_string from the fmt module (fmtlib#3970, fmtlib#3999). Thanks @matt77hias and @yujincheng08.

  • Improved integration with stdio in fmt::print, enabling direct writes into a C stream buffer in common cases. This may give significant performance improvements ranging from tens of percent to 2x and eliminates dynamic memory allocations on the buffer level. It is currently enabled for built-in and string types with wider availability coming up in future releases.

    For example, it gives ~24% improvement on a simple benchmark compiled with Apple clang version 15.0.0 (clang-1500.1.0.2.5) and run on macOS 14.2.1:

    -------------------------------------------------------
    Benchmark             Time             CPU   Iterations
    -------------------------------------------------------
    printf             81.8 ns         81.5 ns      8496899
    fmt::print (10.x)  63.8 ns         61.9 ns     11524151
    fmt::print (11.0)  51.3 ns         51.0 ns     13846580
    
  • Improved safety of fmt::format_to when writing to an array (fmtlib#3805). For example (godbolt):

    auto volkswagen = char[4];
    auto result = fmt::format_to(volkswagen, "elephant");

    no longer results in a buffer overflow. Instead the output will be truncated and you can get the end iterator and whether truncation occurred from the result object. Thanks @ThePhD.

  • Enabled Unicode support by default in MSVC, bringing it on par with other compilers and making it unnecessary for users to enable it explicitly. Most of {fmt} is encoding-agnostic but this prevents mojibake in places where encoding matters such as path formatting and terminal output. You can control the Unicode support via the CMake FMT_UNICODE option. Note that some {fmt} packages such as the one in vcpkg have already been compiled with Unicode enabled.

  • Added a formatter for std::expected (fmtlib#3834). Thanks @dominicpoeschko.

  • Added a formatter for std::complex (fmtlib#1467, fmtlib#3886, fmtlib#3892, fmtlib#3900). Thanks @phprus.

  • Added a formatter for std::type_info (fmtlib#3978). Thanks @matt77hias.

  • Specialized formatter for std::basic_string types with custom traits and allocators (fmtlib#3938, fmtlib#3943). Thanks @dieram3.

  • Added formatters for std::chrono::day, std::chrono::month, std::chrono::year and std::chrono::year_month_day (fmtlib#3758, fmtlib#3772, fmtlib#3906, fmtlib#3913). For example:

    #include <fmt/chrono.h>
    #include <fmt/color.h>
    
    int main() {
      fmt::print(fg(fmt::color::green), "{}\n", std::chrono::day(7));
    }

    prints a green day:

    image

    Thanks @zivshek.

  • Fixed handling of precision in %S (fmtlib#3794, fmtlib#3814). Thanks @js324.

  • Added support for the - specifier (glibc strftime extension) to day of the month (%d) and week of the year (%W, %U, %V) specifiers (fmtlib#3976). Thanks @ZaheenJ.

  • Fixed the scope of the - extension in chrono formatting so that it doesn't apply to subsequent specifiers (fmtlib#3811, fmtlib#3812). Thanks @phprus.

  • Improved handling of time_point::min() (fmtlib#3282).

  • Added support for character range formatting (fmtlib#3857, fmtlib#3863). Thanks @js324.

  • Added string and debug_string range formatters (fmtlib#3973, fmtlib#4024). Thanks @matt77hias.

  • Enabled ADL for begin and end in fmt::join (fmtlib#3813, fmtlib#3824). Thanks @bbolli.

  • Made contiguous iterator optimizations apply to std::basic_string iterators (fmtlib#3798). Thanks @phprus.

  • Added support for ranges with mutable begin and end (fmtlib#3752, fmtlib#3800, fmtlib#3955). Thanks @tcbrindle and @Arghnews.

  • Added support for move-only iterators to fmt::join (fmtlib#3802, fmtlib#3946). Thanks @Arghnews.

  • Moved range and iterator overloads of fmt::join to fmt/ranges.h, next to other overloads.

  • Fixed handling of types with begin returning void such as Eigen matrices (fmtlib#3839, fmtlib#3964). Thanks @Arghnews.

  • Added an fmt::formattable concept (fmtlib#3974). Thanks @matt77hias.

  • Added support for __float128 (fmtlib#3494).

  • Fixed rounding issues when formatting long double with fixed precision (fmtlib#3539).

  • Made fmt::isnan not trigger floating-point exception for NaN values (fmtlib#3948, fmtlib#3951). Thanks @alexdewar.

  • Removed dependency on <memory> for std::allocator_traits when possible (fmtlib#3804). Thanks @phprus.

  • Enabled compile-time checks in formatting functions that take text colors and styles.

  • Deprecated wide stream overloads of fmt::print that take text styles.

  • Made format string compilation work with clang 12 and later despite only partial non-type template parameter support (fmtlib#4000, fmtlib#4001). Thanks @yujincheng08.

  • Made fmt::iterator_buffer's move constructor noexcept (fmtlib#3808). Thanks @waywardmonkeys.

  • Started enforcing that formatter::format is const for compatibility with std::format (fmtlib#3447).

  • Added fmt::basic_format_arg::visit and deprecated fmt::visit_format_arg.

  • Made fmt::basic_string_view not constructible from nullptr for consistency with std::string_view in C++23 (fmtlib#3846). Thanks @dalle.

  • Fixed fmt::group_digits for negative integers (fmtlib#3891, fmtlib#3901). Thanks @phprus.

  • Fixed handling of negative ids in fmt::basic_format_args::get (fmtlib#3945). Thanks @marlenecota.

  • Improved named argument validation (fmtlib#3817).

  • Disabled copy construction/assignment for fmt::format_arg_store and fixed moved construction (fmtlib#3833). Thanks @ivafanas.

  • Worked around a locale issue in RHEL/devtoolset (fmtlib#3858, fmtlib#3859). Thanks @g199209.

  • Added RTTI detection for MSVC (fmtlib#3821, fmtlib#3963). Thanks @edo9300.

  • Migrated the documentation from Sphinx to MkDocs.

  • Improved documentation and README (fmtlib#3775, fmtlib#3784, fmtlib#3788, fmtlib#3789, fmtlib#3793, fmtlib#3818, fmtlib#3820, fmtlib#3822, fmtlib#3843, fmtlib#3890, fmtlib#3894, fmtlib#3895, fmtlib#3905, fmtlib#3942, fmtlib#4008). Thanks @zencatalyst, WolleTD, @tupaschoal, @Dobiasd, @frank-weinberg, @bbolli, @phprus, @waywardmonkeys, @js324 and @tchaikov.

  • Improved CI and tests (fmtlib#3878, fmtlib#3883, fmtlib#3897, fmtlib#3979, fmtlib#3980, fmtlib#3988, fmtlib#4010, fmtlib#4012, fmtlib#4038). Thanks @vgorrX, @waywardmonkeys, @tchaikov and @phprus.

  • Fixed buffer overflow when using format string compilation with debug format and std::back_insert_iterator (fmtlib#3795, fmtlib#3797). Thanks @phprus.

  • Improved Bazel support (fmtlib#3792, fmtlib#3801, fmtlib#3962, fmtlib#3965). Thanks @Vertexwahn.

  • Improved/fixed the CMake config (fmtlib#3777, fmtlib#3783, fmtlib#3847, fmtlib#3907). Thanks @phprus and @xTachyon.

  • Fixed various warnings and compilation issues (fmtlib#3685, fmtlib#3769, fmtlib#3796, fmtlib#3803, fmtlib#3806, fmtlib#3807, fmtlib#3809, fmtlib#3810, fmtlib#3830, fmtlib#3832, fmtlib#3835, fmtlib#3844, fmtlib#3854, fmtlib#3856, fmtlib#3865, fmtlib#3866, fmtlib#3880, fmtlib#3881, fmtlib#3884, fmtlib#3898, fmtlib#3899, fmtlib#3909, fmtlib#3917, fmtlib#3923, fmtlib#3924, fmtlib#3925, fmtlib#3930, fmtlib#3931, fmtlib#3933, fmtlib#3935, fmtlib#3937, fmtlib#3967, fmtlib#3968, fmtlib#3972, fmtlib#3983, fmtlib#3992, fmtlib#3995, fmtlib#4009, fmtlib#4023). Thanks @hmbj, @phprus, @res2k, @Baardi, @matt77hias, @waywardmonkeys, @hmbj, @yakra, @prlw1, @Arghnews, @mtillmann0, @ShifftC, @eepp, @jimmy-park and @ChristianGebhardt.

10.2.1 - 2024-01-04

10.2.0 - 2024-01-01

10.1.1 - 2023-08-28

10.1.0 - 2023-08-12

  • Optimized format string compilation resulting in up to 40% speed up in compiled format_to and ~4x speed up in compiled format_to_n on a concatenation benchmark (fmtlib#3133, fmtlib#3484).

    {fmt} 10.0:

    ---------------------------------------------------------
    Benchmark               Time             CPU   Iterations
    ---------------------------------------------------------
    BM_format_to         78.9 ns         78.9 ns      8881746
    BM_format_to_n        568 ns          568 ns      1232089
    

    {fmt} 10.1:

    ---------------------------------------------------------
    Benchmark               Time             CPU   Iterations
    ---------------------------------------------------------
    BM_format_to         54.9 ns         54.9 ns     12727944
    BM_format_to_n        133 ns          133 ns      5257795
    
  • Optimized storage of an empty allocator in basic_memory_buffer (fmtlib#3485). Thanks @Minty-Meeo.

  • Added formatters for proxy references to elements of std::vector<bool> and std::bitset<N> (fmtlib#3567, fmtlib#3570). For example (godbolt):

    #include <vector>
    #include <fmt/std.h>
    
    int main() {
      auto v = std::vector<bool>{true};
      fmt::print("{}", v[0]);
    }

    Thanks @phprus and @felix642.

  • Fixed an ambiguous formatter specialization for containers that look like container adaptors such as boost::flat_set (fmtlib#3556, fmtlib#3561). Thanks @5chmidti.

  • Fixed compilation when formatting durations not convertible from std::chrono::seconds (fmtlib#3430). Thanks @patlkli.

  • Made the formatter specialization for char* const-correct (fmtlib#3432). Thanks @timsong-cpp.

  • Made {} and {:} handled consistently during compile-time checks (fmtlib#3526).

  • Disallowed passing temporaries to make_format_args to improve API safety by preventing dangling references.

  • Improved the compile-time error for unformattable types (fmtlib#3478). Thanks @BRevzin.

  • Improved the floating-point formatter (fmtlib#3448, fmtlib#3450). Thanks @florimond-collette.

  • Fixed handling of precision for long double larger than 64 bits. (fmtlib#3539, fmtlib#3564).

  • Made floating-point and chrono tests less platform-dependent (fmtlib#3337, fmtlib#3433, fmtlib#3434). Thanks @phprus.

  • Removed the remnants of the Grisu floating-point formatter that has been replaced by Dragonbox in earlier versions.

  • Added throw_format_error to the public API (fmtlib#3551). Thanks @mjerabek.

  • Made FMT_THROW assert even if assertions are disabled when compiling with exceptions disabled (fmtlib#3418, fmtlib#3439). Thanks @BRevzin.

  • Made format_as and std::filesystem::path formatter work with exotic code unit types. (fmtlib#3457, fmtlib#3476). Thanks @gix and @hmbj.

  • Added support for the ? format specifier to std::filesystem::path and made the default unescaped for consistency with strings.

  • Deprecated the wide stream overload of printf.

  • Removed unused basic_printf_parse_context.

  • Improved RTTI detection used when formatting exceptions (fmtlib#3468). Thanks @danakj.

  • Improved compatibility with VxWorks7 (fmtlib#3467). Thanks @wenshan1.

  • Improved documentation (fmtlib#3174, fmtlib#3423, fmtlib#3454, fmtlib#3458, fmtlib#3461, fmtlib#3487, fmtlib#3515). Thanks @zencatalyst, @rlalik and @mikecrowe.

  • Improved build and CI configurations (fmtlib#3449, fmtlib#3451, fmtlib#3452, fmtlib#3453, fmtlib#3459, fmtlib#3481, fmtlib#3486, fmtlib#3489, fmtlib#3496, fmtlib#3517, fmtlib#3523, fmtlib#3563). Thanks @joycebrum, @glebm, @phprus, @petrmanek, @setoye and @abouvier.

  • Fixed various warnings and compilation issues (fmtlib#3408, fmtlib#3424, fmtlib#3444, fmtlib#3446, fmtlib#3475, fmtlib#3482, fmtlib#3492, fmtlib#3493, fmtlib#3508, fmtlib#3509, fmtlib#3533, fmtlib#3542, fmtlib#3543, fmtlib#3540, fmtlib#3544, fmtlib#3548, fmtlib#3549, fmtlib#3550, fmtlib#3552). Thanks @adesitter, @hmbj, @Minty-Meeo, @phprus, @TobiSchluter, @kieranclancy, @alexeedm, @jurihock, @Ozomahtli and @razaqq.

10.0.0 - 2023-05-09

9.1.0 - 2022-08-27

9.0.0 - 2022-07-04

  • Switched 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):

    #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, the algorithm used for the default floating-point formatting (fmtlib#2713, fmtlib#2750). Thanks @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 when fmt/ostream.h is included to prevent ODR violations. You can get the old behavior by defining FMT_DEPRECATED_OSTREAM but this will be removed in the next major release. Use fmt::streamed or fmt::ostream_formatter to enable formatting via std::ostream instead.

  • Added fmt::ostream_formatter that can be used to write formatter specializations that perform formatting via std::ostream. For example (godbolt):

    #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 via std::ostream. For example (godbolt):

    #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 a formatter specialization for std::thread::id so you don't need to format it via std::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 (fmtlib#2941). For example (godbolt):

    #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.

  • Added experimental std::filesystem::path formatting support (fmtlib#2865, fmtlib#2902, fmtlib#2917, fmtlib#2918). For example (godbolt):

    #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.

  • Added a std::thread::id formatter to fmt/std.h. For example (godbolt):

    #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 (fmtlib#2793). For example (godbolt):

    #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

    Thanks @rbrugo.

  • Made fmt::print overload for text styles correctly handle UTF-8 (fmtlib#2681, fmtlib#2701). Thanks @AlexGuteniev.

  • Fixed Unicode handling when writing to an ostream.

  • Added support for nested specifiers to range formatting (fmtlib#2673). For example (godbolt):

    #include <vector>
    #include <fmt/ranges.h>
    
    int main() {
      fmt::print("{::#x}\n", std::vector{10, 20, 30});
    }

    prints [0xa, 0x14, 0x1e].

    Thanks @BRevzin.

  • Implemented escaping of wide strings in ranges (fmtlib#2904). Thanks @phprus.

  • Added support for ranges with begin / end found via the argument-dependent lookup (fmtlib#2807). Thanks @rbrugo.

  • Fixed formatting of certain kinds of ranges of ranges (fmtlib#2787). Thanks @BRevzin.

  • Fixed handling of maps with element types other than std::pair (fmtlib#2944). Thanks @BrukerJWD.

  • Made tuple formatter enabled only if elements are formattable (fmtlib#2939, fmtlib#2940). Thanks @jehelset.

  • Made fmt::join compatible with format string compilation (fmtlib#2719, fmtlib#2720). Thanks @phprus.

  • Made compile-time checks work with named arguments of custom types and std::ostream print overloads (fmtlib#2816, fmtlib#2817, fmtlib#2819). Thanks @timsong-cpp.

  • Removed make_args_checked because it is no longer needed for compile-time checks (fmtlib#2760). Thanks @phprus.

  • Removed the following deprecated APIs: _format, arg_join, the format_to overload that takes a memory buffer, [v]fprintf that takes an ostream.

  • 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() with descriptor() in buffered_file.

  • Moved to_string_view to the detail namespace since it's an implementation detail.

  • Made access mode of a created file consistent with fopen by setting S_IWGRP and S_IWOTH (fmtlib#2733). Thanks @arogge.

  • Removed a redundant buffer resize when formatting to std::ostream (fmtlib#2842, fmtlib#2843). Thanks @jcelerier.

  • Made precision computation for strings consistent with width (fmtlib#2888).

  • Fixed handling of locale separators in floating point formatting (fmtlib#2830).

  • Made sign specifiers work with __int128_t (fmtlib#2773).

  • Improved support for systems such as CHERI with extra data stored in pointers (fmtlib#2932). Thanks @davidchisnall.

  • Improved documentation (fmtlib#2706, fmtlib#2712, fmtlib#2789, fmtlib#2803, fmtlib#2805, fmtlib#2815, fmtlib#2924). Thanks @BRevzin, @Pokechu22, @setoye, @rtobar, @rbrugo, @anoonD and @leha-bot.

  • Improved build configuration (fmtlib#2766, fmtlib#2772, fmtlib#2836, fmtlib#2852, fmtlib#2907, fmtlib#2913, fmtlib#2914). Thanks @kambala-decapitator, @mattiasljungstrom, @kieselnb, @nathannaveen and @Vertexwahn.

  • Fixed various warnings and compilation issues (fmtlib#2408, fmtlib#2507, fmtlib#2697, fmtlib#2715, fmtlib#2717, fmtlib#2722, fmtlib#2724, fmtlib#2725, fmtlib#2726, fmtlib#2728, fmtlib#2732, fmtlib#2738, fmtlib#2742, fmtlib#2744, fmtlib#2745, fmtlib#2746, fmtlib#2754, fmtlib#2755, fmtlib#2757, fmtlib#2758, fmtlib#2761, fmtlib#2762, fmtlib#2763, fmtlib#2765, fmtlib#2769, fmtlib#2770, fmtlib#2771, fmtlib#2777, fmtlib#2779, fmtlib#2782, fmtlib#2783, fmtlib#2794, fmtlib#2796, fmtlib#2797, fmtlib#2801, fmtlib#2802, fmtlib#2808, fmtlib#2818, fmtlib#2819, fmtlib#2829, fmtlib#2835, fmtlib#2848, fmtlib#2860, fmtlib#2861, fmtlib#2882, fmtlib#2886, fmtlib#2891, fmtlib#2892, fmtlib#2895, fmtlib#2896, fmtlib#2903, fmtlib#2906, fmtlib#2908, fmtlib#2909, fmtlib#2920, fmtlib#2922, fmtlib#2927, fmtlib#2929, fmtlib#2936, fmtlib#2937, fmtlib#2938, fmtlib#2951, fmtlib#2954, fmtlib#2957, fmtlib#2958, fmtlib#2960). Thanks @matrackif @Tobi823, @ivan-volnov, @VasiliPupkin256, @federico-busato, @barcharcraz, @jk-jeon, @HazardyKnusperkeks, @dalboris, @seanm, @gsjaardema, @timsong-cpp, @seanm, @frithrah, @chronoxor, @Agga, @madmaxoft, @JurajX, @phprus and @Dani-Hub.

8.1.1 - 2022-01-06

8.1.0 - 2022-01-02

8.0.1 - 2021-07-02

8.0.0 - 2021-06-21

  • Enabled compile-time format string checks by default. For example (godbolt):

    #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+) because d is not a valid format specifier for a string.

    To pass a runtime string wrap it in fmt::runtime:

    fmt::print(fmt::runtime("{:d}"), "I am not a number");
  • Added compile-time formatting (fmtlib#2019, fmtlib#2044, fmtlib#2056, fmtlib#2072, fmtlib#2075, fmtlib#2078, fmtlib#2129, fmtlib#2326). For example (godbolt):

    #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.

  • Optimized handling of format specifiers during format string compilation. For example, hexadecimal formatting ("{:x}") is now 3-7x faster than before when using format_to with format string compilation and a stack-allocated buffer (fmtlib#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 the FMT_COMPILE macro (fmtlib#2043, fmtlib#2242):

    #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.

  • Format string compilation now requires format functions of formatter specializations for user-defined types to be const:

    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 (fmtlib#2243, fmtlib#2281). For example:

    #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.

  • Added format string compilation support to fmt::print (fmtlib#2280, fmtlib#2304). Thanks @alexezeder.

  • Added initial support for compiling {fmt} as a C++20 module (fmtlib#2235, fmtlib#2240, fmtlib#2260, fmtlib#2282, fmtlib#2283, fmtlib#2288, fmtlib#2298, fmtlib#2306, fmtlib#2307, fmtlib#2309, fmtlib#2318, fmtlib#2324, fmtlib#2332, fmtlib#2340). Thanks @DanielaE.

  • Made symbols private by default reducing shared library size (fmtlib#2301). For example there was a ~15% reported reduction on one platform. Thanks @sergiud.

  • Optimized includes making the result of preprocessing fmt/format.h ~20% smaller with libstdc++/C++20 and slightly improving build times (fmtlib#1998).

  • Added support of ranges with non-const begin / end (fmtlib#1953). Thanks @kitegi.

  • Added support of std::byte and other formattable types to fmt::join (fmtlib#1981, fmtlib#2040, fmtlib#2050, fmtlib#2262). For example:

    #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.

  • Implemented the default format for std::chrono::system_clock (fmtlib#2319, fmtlib#2345). For example:

    #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.

  • Made more chrono specifiers locale independent by default. Use the 'L' specifier to get localized formatting. For example:

    #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 (fmtlib#2337, fmtlib#2349, fmtlib#2350). Thanks @phprus.

  • Deprecated fmt/locale.h moving the formatting functions that take a locale to fmt/format.h (char) and fmt/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 takes basic_memory_buffer.

  • Made parameter order in vformat_to consistent with format_to (fmtlib#2327).

  • Added support for time points with arbitrary durations (fmtlib#2208). For example:

    #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".

  • Formatting floating-point numbers no longer produces trailing zeros by default for consistency with std::format. For example:

    #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's str.format.

  • The 'L' specifier for locale-specific numeric formatting can now be combined with presentation specifiers as in std::format. For example:

    #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 (fmtlib#2305, fmtlib#2310). Thanks @Liedtke.

  • Made the hexfloat formatting use the right alignment by default (fmtlib#2308, fmtlib#2317). Thanks @Liedtke.

  • Removed the deprecated numeric alignment ('='). Use the '0' specifier instead.

  • Removed the deprecated fmt/posix.h header that has been replaced with fmt/os.h.

  • Removed the deprecated format_to_n_context, format_to_n_args and make_format_to_n_args. They have been replaced with format_context, format_args` andmake_format_args`` respectively.

  • Moved wchar_t-specific functions and types to fmt/xchar.h. You can define FMT_DEPRECATED_INCLUDE_XCHAR to automatically include fmt/xchar.h from fmt/format.h but this will be disabled in the next major release.

  • Fixed handling of the '+' specifier in localized formatting (fmtlib#2133).

  • Added support for the 's' format specifier that gives textual representation of bool (fmtlib#2094, fmtlib#2109). For example:

    #include <fmt/core.h>
    
    int main() {
      fmt::print("{:s}", true);
    }

    prints "true". Thanks @powercoderlol.

  • Made fmt::ptr work with function pointers (fmtlib#2131). For example:

    #include <fmt/format.h>
    
    int main() {
      fmt::print("My main: {}\n", fmt::ptr(main));
    }

    Thanks @mikecrowe.

  • The undocumented support for specializing formatter for pointer types has been removed.

  • Fixed fmt::formatted_size with format string compilation (fmtlib#2141, fmtlib#2161). Thanks @alexezeder.

  • Fixed handling of empty format strings during format string compilation (fmtlib#2042):

    auto s = fmt::format(FMT_COMPILE(""));

    Thanks @alexezeder.

  • Fixed handling of enums in fmt::to_string (fmtlib#2036).

  • Improved width computation (fmtlib#2033, fmtlib#2091). For example:

    #include <fmt/core.h>
    
    int main() {
      fmt::print("{:-<10}{}\n", "你好", "世界");
      fmt::print("{:-<10}{}\n", "hello", "world");
    }

    prints

    on a modern terminal.

  • The experimental fast output stream (fmt::ostream) is now truncated by default for consistency with fopen (fmtlib#2018). For example:

    #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 to fmt::output_file.

  • Fixed moving of fmt::ostream that holds buffered data (fmtlib#2197, fmtlib#2198). Thanks @vtta.

  • Replaced the fmt::system_error exception with a function of the same name that constructs std::system_error (fmtlib#2266).

  • Replaced the fmt::windows_error exception with a function of the same name that constructs std::system_error with the category returned by fmt::system_category() (fmtlib#2274, fmtlib#2275). The latter is similar to std::system_category but correctly handles UTF-8. Thanks @phprus.

  • Replaced fmt::error_code with std::error_code and made it formattable (fmtlib#2269, fmtlib#2270, fmtlib#2273). Thanks @phprus.

  • Added speech synthesis support (fmtlib#2206).

  • Made format_to work with a memory buffer that has a custom allocator (fmtlib#2300). Thanks @voxmea.

  • Added Allocator::max_size support to basic_memory_buffer. (fmtlib#1960). Thanks @phprus.

  • Added wide string support to fmt::join (fmtlib#2236). Thanks @crbrz.

  • Made iterators passed to formatter specializations via a format context satisfy C++20 std::output_iterator requirements (fmtlib#2156, fmtlib#2158, fmtlib#2195, fmtlib#2204). Thanks @randomnetcat.

  • Optimized the printf implementation (fmtlib#1982, fmtlib#1984, fmtlib#2016, fmtlib#2164). Thanks @rimathia and @moiwi.

  • Improved detection of constexpr char_traits (fmtlib#2246, fmtlib#2257). Thanks @phprus.

  • Fixed writing to stdout when it is redirected to NUL on Windows (fmtlib#2080).

  • Fixed exception propagation from iterators (fmtlib#2097).

  • Improved strftime error handling (fmtlib#2238, fmtlib#2244). Thanks @yumeyao.

  • Stopped using deprecated GCC UDL template extension.

  • Added fmt/args.h to the install target (fmtlib#2096).

  • Error messages are now passed to assert when exceptions are disabled (fmtlib#2145). Thanks @NobodyXu.

  • Added the FMT_MASTER_PROJECT CMake option to control build and install targets when {fmt} is included via add_subdirectory (fmtlib#2098, fmtlib#2100). Thanks @randomizedthinking.

  • Improved build configuration (fmtlib#2026, fmtlib#2122). Thanks @luncliff and @ibaned.

  • Fixed various warnings and compilation issues (fmtlib#1947, fmtlib#1959, fmtlib#1963, fmtlib#1965, fmtlib#1966, fmtlib#1974, fmtlib#1975, fmtlib#1990, fmtlib#2000, fmtlib#2001, fmtlib#2002, fmtlib#2004, fmtlib#2006, fmtlib#2009, fmtlib#2010, fmtlib#2038, fmtlib#2039, fmtlib#2047, fmtlib#2053, fmtlib#2059, fmtlib#2065, fmtlib#2067, fmtlib#2068, fmtlib#2073, fmtlib#2103, fmtlib#2105, fmtlib#2106, fmtlib#2107, fmtlib#2116, fmtlib#2117, fmtlib#2118, fmtlib#2119, fmtlib#2127, fmtlib#2128, fmtlib#2140, fmtlib#2142, fmtlib#2143, fmtlib#2144, fmtlib#2147, fmtlib#2148, fmtlib#2149, fmtlib#2152, fmtlib#2160, fmtlib#2170, fmtlib#2175, fmtlib#2176, fmtlib#2177, fmtlib#2178, fmtlib#2179, fmtlib#2180, fmtlib#2181, fmtlib#2183, fmtlib#2184, fmtlib#2185, fmtlib#2186, fmtlib#2187, fmtlib#2190, fmtlib#2192, fmtlib#2194, fmtlib#2205, fmtlib#2210, fmtlib#2211, fmtlib#2215, fmtlib#2216, fmtlib#2218, fmtlib#2220, fmtlib#2228, fmtlib#2229, fmtlib#2230, fmtlib#2233, fmtlib#2239, fmtlib#2248, fmtlib#2252, fmtlib#2253, fmtlib#2255, fmtlib#2261, fmtlib#2278, fmtlib#2284, fmtlib#2287, fmtlib#2289, fmtlib#2290, fmtlib#2293, fmtlib#2295, fmtlib#2296, fmtlib#2297, fmtlib#2311, fmtlib#2313, fmtlib#2315, fmtlib#2320, fmtlib#2321, fmtlib#2323, fmtlib#2328, fmtlib#2329, fmtlib#2333, fmtlib#2338, fmtlib#2341). Thanks @darklukee, @fagg, @killerbot242, @jgopel, @yeswalrus, @Finkman, @HazardyKnusperkeks, @dkavolis, @concatime, @chronoxor, @summivox, @yNeo, @Apache-HB, @alexezeder, @toojays, @Brainy0207, @vadz, @imsherlock, @phprus, @white238, @yafshar, @BillyDonahue, @jstaahl, @denchat, @DanielaE, @ilyakurdyukov, @ilmai, @JessyDL, @sergiud, @mwinterb, @sven-herrmann, @jmelas, @twoixter, @crbrz and @upsj.

  • Improved documentation (fmtlib#1986, fmtlib#2051, fmtlib#2057, fmtlib#2081, fmtlib#2084, fmtlib#2312). Thanks @imba-tjd, @0x416c69 and @mordante.

  • Continuous integration and test improvements (fmtlib#1969, fmtlib#1991, fmtlib#2020, fmtlib#2110, fmtlib#2114, fmtlib#2196, fmtlib#2217, fmtlib#2247, fmtlib#2256, fmtlib#2336, fmtlib#2346). Thanks @jgopel, @alexezeder and @DanielaE.

The change log for versions 0.8.0 - 7.1.3 is available here.