Skip to content

Latest commit

 

History

History
3225 lines (2556 loc) · 115 KB

File metadata and controls

3225 lines (2556 loc) · 115 KB

12.0.0 - 2025-09-17

  • Optimized the default floating point formatting (fmtlib#3675, fmtlib#4516). In particular, formatting a double with format string compilation into a stack allocated buffer is more than 60% faster in version 12.0 compared to 11.2 according to dtoa-benchmark:

    Function  Time (ns)  Speedup
    fmt11        34.471    1.00x
    fmt12        21.000    1.64x
    
  • Added constexpr support to fmt::format. For example:

    #include <fmt/compile.h>
    
    using namespace fmt::literals;
    std::string s = fmt::format(""_cf, 42);

    now works at compile time provided that std::string supports constexpr (fmtlib#3403, fmtlib#4456). Thanks @msvetkin.

  • Added FMT_STATIC_FORMAT that allows formatting into a string of the exact required size at compile time.

    For example:

    #include <fmt/compile.h>
    
    constexpr auto s = FMT_STATIC_FORMAT("{}", 42);

    compiles to just

    __ZL1s:
          .asciiz "42"

    It can be accessed as a C string with s.c_str() or as a string view with s.str().

  • Improved C++20 module support (fmtlib#4451, fmtlib#4459, fmtlib#4476, fmtlib#4488, fmtlib#4491, fmtlib#4495). Thanks @arBmind, @tkhyn, @Mishura4, @anonymouspc and @autoantwort.

  • Switched to using estimated display width in precision. For example:

    fmt::print("|{:.4}|\n|1234|\n", "🐱🐱🐱");

    prints

    because 🐱 has an estimated width of 2 (fmtlib#4272, fmtlib#4443, fmtlib#4475). Thanks @nikhilreddydev and @localspook.

  • Fix interaction between debug presentation, precision, and width for strings (fmtlib#4478). Thanks @localspook.

  • Implemented allocator propagation on basic_memory_buffer move (fmtlib#4487, fmtlib#4490). Thanks @toprakmurat.

  • Fixed an ambiguity between std::reference_wrapper<T> and format_as formatters (fmtlib#4424, fmtlib#4434). Thanks @jeremy-rifkin.

  • Removed the following deprecated APIs:

    • has_formatter: use is_formattable instead,
    • basic_format_args::parse_context_type, basic_format_args::formatter_type and similar aliases in context types,
    • wide stream overload of fmt::printf,
    • wide stream overloads of fmt::print that take text styles,
    • is_*char traits,
    • fmt::localtime.
  • Deprecated wide overloads of fmt::fprintf and fmt::sprintf.

  • Improved diagnostics for the incorrect usage of fmt::ptr (fmtlib#4453). Thanks @TobiSchluter.

  • Made handling of ANSI escape sequences more efficient (fmtlib#4511, fmtlib#4528). Thanks @localspook and @Anas-Hamdane.

  • Fixed a buffer overflow on all emphasis flags set (fmtlib#4498). Thanks @dominicpoeschko.

  • Fixed an integer overflow for precision close to the max int value.

  • Fixed compatibility with WASI (fmtlib#4496, fmtlib#4497). Thanks @whitequark.

  • Fixed back_insert_iterator detection, preventing a fallback on slower path that handles arbitrary iterators (fmtlib#4454).

  • Fixed handling of invalid glibc FILE buffers (fmtlib#4469).

  • Added wchar_t support to the std::byte formatter (fmtlib#4479, fmtlib#4480). Thanks @phprus.

  • Changed component prefix from fmt- to fmt_ for compatibility with NSIS/CPack on Windows, e.g. fmt-doc changed to fmt_doc (fmtlib#4441, fmtlib#4442). Thanks @n-stein.

  • Added the FMT_CUSTOM_ASSERT_FAIL macro to simplify providing a custom fmt::assert_fail implementation (fmtlib#4505). Thanks @HazardyKnusperkeks.

  • Switched to FMT_THROW on reporting format errors so that it can be overriden by users when exceptions are disabled (fmtlib#4521). Thanks @HazardyKnusperkeks.

  • Improved master project detection and disabled install targets when using {fmt} as a subproject by default (fmtlib#4536). Thanks @crueter.

  • Made various code improvements (fmtlib#4445, fmtlib#4448, fmtlib#4473, fmtlib#4522). Thanks @localspook, @tchaikov and @way4sahil.

  • Added Conan instructions to the docs (fmtlib#4537). Thanks @uilianries.

  • Removed Bazel files to avoid issues with downstream packaging (fmtlib#4530). Thanks @mering.

  • Added more entries for generated files to .gitignore (fmtlib#4355, fmtlib#4512). Thanks @dinomight and @localspook.

  • Fixed various warnings and compilation issues (fmtlib#4447, fmtlib#4470, fmtlib#4474, fmtlib#4477, fmtlib#4471, fmtlib#4483, fmtlib#4515, fmtlib#4533, fmtlib#4534). Thanks @dodomorandi, @localspook, @remyjette, @Tomek-Stolarczyk, @Mishura4, @mattiasljungstrom and @FatihBAKIR.

11.2.0 - 2025-05-03

  • Added the s specifier for std::error_code. It allows formatting an error message as a string. For example:

    #include <fmt/std.h>
    
    int main() {
      auto ec = std::make_error_code(std::errc::no_such_file_or_directory);
      fmt::print("{:s}\n", ec);
    }

    prints

    No such file or directory
    

    (The actual message is platform-specific.)

  • Fixed formatting of std::chrono::local_time and tm (fmtlib#3815, fmtlib#4350). For example (godbolt):

    #include <fmt/chrono.h>
    
    int main() {
      std::chrono::zoned_time zt(
        std::chrono::current_zone(),
        std::chrono::system_clock::now());
      fmt::print("{}", zt.get_local_time());
    }

    is now formatted consistenly across platforms.

  • Added diagnostics for cases when timezone information is not available. For example:

    fmt::print("{:Z}", std::chrono::local_seconds());

    now gives a compile-time error.

  • Deprecated fmt::localtime in favor of std::localtime.

  • Fixed compilation with GCC 15 and C++20 modules enabled (fmtlib#4347). Thanks @tkhyn.

  • Fixed handling of named arguments in format specs (fmtlib#4360, fmtlib#4361). Thanks @dinomight.

  • Added error reporting for duplicate named arguments (fmtlib#4282, fmtlib#4367). Thanks @dinomight.

  • Fixed formatting of long with FMT_BUILTIN_TYPES=0 (fmtlib#4375, fmtlib#4394).

  • Optimized text_style using bit packing (fmtlib#4363). Thanks @localspook.

  • Added support for incomplete types (fmtlib#3180, fmtlib#4383). Thanks @localspook.

  • Fixed a flush issue in fmt::print when using libstdc++ (fmtlib#4398).

  • Fixed fmt::println usage with FMT_ENFORCE_COMPILE_STRING and legacy compile-time checks (fmtlib#4407). Thanks @madmaxoft.

  • Removed legacy header fmt/core.h from docs (fmtlib#4421, fmtlib#4422). Thanks @krzysztofkortas.

  • Worked around limitations of __builtin_strlen during constant evaluation (fmtlib#4423, fmtlib#4429). Thanks @BRevzin.

  • Worked around a bug in MSVC v141 (fmtlib#4412, fmtlib#4413). Thanks @hirohira9119.

  • Removed the fmt_detail namespace (fmtlib#4324).

  • Removed specializations of std::is_floating_point in tests (fmtlib#4417).

  • Fixed a CMake error when setting CMAKE_MODULE_PATH in the pedantic mode (fmtlib#4426). Thanks @rlalik.

  • Updated the Bazel config (fmtlib#4400). Thanks @Vertexwahn.

11.1.4 - 2025-02-26

  • Fixed ABI compatibility with earlier 11.x versions on Windows (fmtlib#4359).

  • Improved the logic of switching between fixed and exponential format for float (fmtlib#3649).

  • Moved is_compiled_string to the public API (fmtlib#4335, fmtlib#4342). Thanks @SwooshyCueb.

  • Simplified implementation of operator""_cf (fmtlib#4349). Thanks @localspook.

  • Fixed __builtin_strlen detection (fmtlib#4329). Thanks @localspook.

  • Fixed handling of BMI paths with the Ninja generator (fmtlib#4344). Thanks @tkhyn.

  • Fixed gcc 8.3 compile errors (fmtlib#4331, fmtlib#4336). Thanks @sergiud.

  • Fixed a bogus MSVC warning (fmtlib#4356). Thanks @dinomight.

11.1.3 - 2025-01-25

  • Fixed compilation on GCC 9.4 (fmtlib#4313).

  • Worked around an internal compiler error when using C++20 modules with GCC 14.2 and earlier (fmtlib#4295).

  • Worked around a bug in GCC 6 (fmtlib#4318).

  • Fixed an issue caused by instantiating formatter<const T> (fmtlib#4303, fmtlib#4325). Thanks @timsong-cpp.

  • Fixed formatting into std::ostreambuf_iterator when using format string compilation (fmtlib#4309, fmtlib#4312). Thanks @phprus.

  • Restored a constraint on the map formatter so that it correctly reports as unformattable when the element is (fmtlib#4326). Thanks @timsong-cpp.

  • Reduced the size of format specs (fmtlib#4298).

  • Readded args() to fmt::format_context (fmtlib#4307, fmtlib#4310). Thanks @Erroneous1.

  • Fixed a bogus MSVC warning (fmtlib#4314, fmtlib#4322). Thanks @ZehMatt.

  • Fixed a pedantic mode error in the CMake config (fmtlib#4327). Thanks @rlalik.

11.1.2 - 2025-01-12

11.1.1 - 2024-12-27

  • Fixed ABI compatibility with earlier 11.x versions (fmtlib#4278).

  • Defined CMake components (core and doc) to allow docs to be installed separately (fmtlib#4276). Thanks @carlsmedstad.

11.1.0 - 2024-12-25

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.

  • Fixed handling of a buffer boundary on flush (fmtlib#4229).

  • 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

10.0.0 - 2023-05-09

9.1.0 - 2022-08-27

9.0.0 - 2022-07-04

8.1.1 - 2022-01-06

8.1.0 - 2022-01-02

8.0.1 - 2021-07-02

8.0.0 - 2021-06-21

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