Opened 3 months ago

Closed 3 months ago

#20028 closed enhancement (fixed)

fmt-11.0.0

Reported by: Bruce Dubbs Owned by: Bruce Dubbs
Priority: normal Milestone: 12.2
Component: BOOK Version: git
Severity: normal Keywords:
Cc:

Description

New major version.

Change History (3)

comment:1 by Bruce Dubbs, 3 months ago

Owner: changed from blfs-book to Bruce Dubbs
Status: newassigned

comment:2 by Bruce Dubbs, 3 months ago

# 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 from Sphinx to MkDocs.
  • Improved C++20 module support. In particular, native CMake support for modules is now used if available.
  • Added an option to replace standard includes with import std enabled via the FMT_IMPORT_STD macro
  • Exported fmt::range_format, fmt::range_format_kind and fmt::compiled_string from the fmt module
  • 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]( https://stackoverflow.com/a/78457454/471164) 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.
      ```
      -------------------------------------------------------
      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 For example
      ```c++
      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.

  • 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
  • Added a formatter for std::complex
  • Added a formatter for std::type_info
  • Specialized formatter for std::basic_string types with custom traits and allocators
  • Added formatters for std::chrono::day, std::chrono::month, std::chrono::year and std::chrono::year_month_day For example:
      ```c++
      #include <fmt/chrono.h>
      #include <fmt/color.h>
      
      int main() {
        fmt::print(fg(fmt::color::green), "{}\n", std::chrono::day(7));
      }
    
  • Fixed handling of precision in %S
  • Added support for the - specifier (glibc strftime extension) to day of the month (%d) and week of the year (%W, %U, %V) specifiers
  • Fixed the scope of the - extension in chrono formatting so that it doesn't apply to subsequent specifiers
  • Improved handling of time_point::min()
  • Added support for character range formatting
  • Added string and debug_string range formatters
  • Enabled ADL for begin and end in fmt::join
  • Made contiguous iterator optimizations apply to std::basic_string iterators
  • Added support for ranges with mutable begin and end
  • Added support for move-only iterators to fmt::join
  • Moved range and iterator overloads of fmt::join to fmt/ranges.h, next to other overloads.
  • 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 from Sphinx to MkDocs.
  • Improved C++20 module support. In particular, native CMake support for modules is now used if available.
  • Added an option to replace standard includes with import std enabled via the FMT_IMPORT_STD macro
  • Exported fmt::range_format, fmt::range_format_kind and fmt::compiled_string from the fmt module
  • 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]( https://stackoverflow.com/a/78457454/471164) 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.
      ```
      -------------------------------------------------------
      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
      ```
    
  • Fixed handling of types with begin returning void such as Eigen matrices
  • Added an fmt::formattable concept
  • Added support for __float128 (https://github.com/fmtlib/fmt/issues/3494).
  • Fixed rounding issues when formatting long double with fixed precision
  • Made fmt::isnan not trigger floating-point exception for NaN values
  • Removed dependency on <memory> for std::allocator_traits when possible
  • 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
  • Made fmt::iterator_buffer's move constructor noexcept
  • Started enforcing that formatter::format is const for compatibility with std::format
  • 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
  • Fixed fmt::group_digits for negative integers
  • Fixed handling of negative ids in fmt::basic_format_args::get
  • Improved named argument validation
  • Disabled copy construction/assignment for fmt::format_arg_store and fixed moved construction
  • Worked around a locale issue in RHEL/devtoolset
  • Added RTTI detection for MSVC
  • Migrated the documentation from Sphinx to MkDocs.
  • Improved documentation and README
  • Improved CI and tests
  • Fixed buffer overflow when using format string compilation with debug format and std::back_insert_iterator
  • Improved Bazel support
  • Improved/fixed the CMake config

comment:3 by Bruce Dubbs, 3 months ago

Resolution: fixed
Status: assignedclosed

Fixed at commits

40e6b6cbde Update to fmt-11.0.0.
a649d19576 Update to libqalculate-5.2.0.
0c075aa0c8 Update to unix-tree-2.1.2.
11196d674e Update to p11-kit-0.25.4.
Note: See TracTickets for help on using tickets.