C++ Format v6.2.0 Release Notes

Release Date: 2020-04-05 // about 4 years ago
    • πŸ‘Œ Improved error reporting when trying to format an object of a non-formattable type:

    .. code:: c++

     fmt::format("{}", S());
    

    now gives::

    include/fmt/core.h:1015:5: error: static_assert failed due to requirement
    'formattable' "Cannot format argument. To make type T formattable provide a
    formatter<T> specialization:
    https://fmt.dev/latest/api.html#formatting-user-defined-types"
        static_assert(
        ^
    ...
    note: in instantiation of function template specialization
    'fmt::v6::format<char [3], S, char>' requested here
      fmt::format("{}", S());
           ^
    

    if S is not formattable.

    • ⬇️ Reduced the library size by ~10%.

    • πŸ–¨ Always print decimal point if # is specified (#1476 <https://github.com/fmtlib/fmt/issues/1476>, #1498 <https://github.com/fmtlib/fmt/issues/1498>):

    .. code:: c++

     fmt::print("{:#.0f}", 42.0);
    

    now prints 42.

    • Implemented the 'L' specifier for locale-specific numeric formatting to improve compatibility with std::format. The 'n' specifier is now deprecated and will be removed in the next major release.

    • 🏁 Moved OS-specific APIs such as windows_error from fmt/format.h to fmt/os.h. You can define FMT_DEPRECATED_INCLUDE_OS to automatically include fmt/os.h from fmt/format.h for compatibility but this will be disabled in the next major release.

    • βž• Added precision overflow detection in floating-point formatting.

    • Implemented detection of invalid use of fmt::arg.

    • πŸ‘‰ Used type_identity to block unnecessary template argument deduction. Thanks Tim Song.

    • πŸ‘Œ Improved UTF-8 handling (#1109 <https://github.com/fmtlib/fmt/issues/1109>_):

    .. code:: c++

     fmt::print("β”Œ{0:─^{2}}┐\n"
                "β”‚{1: ^{2}}β”‚\n"
                "β””{0:─^{2}}β”˜\n", "", "ΠŸΡ€ΠΈΠ²Π΅Ρ‚, ΠΌΠΈΡ€!", 20);
    

    now prints::

     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚    ΠŸΡ€ΠΈΠ²Π΅Ρ‚, ΠΌΠΈΡ€!    β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    

    on systems that support Unicode.

    • βž• Added experimental dynamic argument storage (#1170 <https://github.com/fmtlib/fmt/issues/1170>, #1584 <https://github.com/fmtlib/fmt/pull/1584>):

    .. code:: c++

     fmt::dynamic_format_arg_store<fmt::format_context> store;
     store.push_back("answer");
     store.push_back(42);
     fmt::vprint("The {} is {}.\n", store);
    

    prints::

     The answer is 42.
    

    Thanks @vsolontsov-ll (Vladimir Solontsov) <https://github.com/vsolontsov-ll>_.

    • Made fmt::join accept initializer_list (#1591 <https://github.com/fmtlib/fmt/pull/1591>). Thanks @Rapotkinnik (Nikolay Rapotkin) <https://github.com/Rapotkinnik>.

    • πŸ›  Fixed handling of empty tuples (#1588 <https://github.com/fmtlib/fmt/issues/1588>_).

    • Fixed handling of output iterators in format_to_n (#1506 <https://github.com/fmtlib/fmt/issues/1506>_).

    • πŸ›  Fixed formatting of std::chrono::duration types to wide output (#1533 <https://github.com/fmtlib/fmt/pull/1533>). Thanks @zeffy (pilao) <https://github.com/zeffy>.

    • βž• Added const begin and end overload to buffers (#1553 <https://github.com/fmtlib/fmt/pull/1553>). Thanks @dominicpoeschko <https://github.com/dominicpoeschko>.

    • πŸ‘‰ Added the ability to disable floating-point formatting via FMT_USE_FLOAT, FMT_USE_DOUBLE and FMT_USE_LONG_DOUBLE macros for extremely memory-constrained embedded system (#1590 <https://github.com/fmtlib/fmt/pull/1590>). Thanks @albaguirre (Alberto Aguirre) <https://github.com/albaguirre>.

    • Made FMT_STRING work with constexpr string_view (#1589 <https://github.com/fmtlib/fmt/pull/1589>). Thanks @scramsby (Scott Ramsby) <https://github.com/scramsby>.

    • πŸ“œ Implemented a minor optimization in the format string parser (#1560 <https://github.com/fmtlib/fmt/pull/1560>). Thanks @IkarusDeveloper <https://github.com/IkarusDeveloper>.

    • πŸ‘Œ Improved attribute detection (#1469 <https://github.com/fmtlib/fmt/pull/1469>, #1475 <https://github.com/fmtlib/fmt/pull/1475>, #1576 <https://github.com/fmtlib/fmt/pull/1576>). Thanks @federico-busato (Federico) <https://github.com/federico-busato>, @chronoxor (Ivan Shynkarenka) <https://github.com/chronoxor>, @refnum <https://github.com/refnum>.

    • πŸ‘Œ Improved documentation (#1481 <https://github.com/fmtlib/fmt/pull/1481>, #1523 <https://github.com/fmtlib/fmt/pull/1523>). Thanks @JackBoosY (JackΒ·BoosΒ·Yu) <https://github.com/JackBoosY>, @imba-tjd (谭九鼎) <https://github.com/imba-tjd>.

    • πŸ›  Fixed symbol visibility on Linux when compiling with -fvisibility=hidden (#1535 <https://github.com/fmtlib/fmt/pull/1535>). Thanks @milianw (Milian Wolff) <https://github.com/milianw>.

    • πŸ— Implemented various build configuration fixes and improvements (#1264 <https://github.com/fmtlib/fmt/issues/1264>, #1460 <https://github.com/fmtlib/fmt/issues/1460>, #1534 <https://github.com/fmtlib/fmt/pull/1534>, #1536 <https://github.com/fmtlib/fmt/issues/1536>, #1545 <https://github.com/fmtlib/fmt/issues/1545>, #1546 <https://github.com/fmtlib/fmt/pull/1546>, #1566 <https://github.com/fmtlib/fmt/issues/1566>, #1582 <https://github.com/fmtlib/fmt/pull/1582>, #1597 <https://github.com/fmtlib/fmt/issues/1597>, #1598 <https://github.com/fmtlib/fmt/pull/1598>). Thanks @ambitslix (Attila M. Szilagyi) <https://github.com/ambitslix>, @jwillikers (Jordan Williams) <https://github.com/jwillikers>, @stac47 (Laurent Stacul) <https://github.com/stac47>_.

    • πŸ›  Fixed various warnings and compilation issues (#1433 <https://github.com/fmtlib/fmt/pull/1433>, #1461 <https://github.com/fmtlib/fmt/issues/1461>, #1470 <https://github.com/fmtlib/fmt/pull/1470>, #1480 <https://github.com/fmtlib/fmt/pull/1480>, #1485 <https://github.com/fmtlib/fmt/pull/1485>, #1492 <https://github.com/fmtlib/fmt/pull/1492>, #1493 <https://github.com/fmtlib/fmt/issues/1493>, #1504 <https://github.com/fmtlib/fmt/issues/1504>, #1505 <https://github.com/fmtlib/fmt/pull/1505>, #1512 <https://github.com/fmtlib/fmt/pull/1512>, #1515 <https://github.com/fmtlib/fmt/issues/1515>, #1516 <https://github.com/fmtlib/fmt/pull/1516>, #1518 <https://github.com/fmtlib/fmt/pull/1518>, #1519 <https://github.com/fmtlib/fmt/pull/1519>, #1520 <https://github.com/fmtlib/fmt/pull/1520>, #1521 <https://github.com/fmtlib/fmt/pull/1521>, #1522 <https://github.com/fmtlib/fmt/pull/1522>, #1524 <https://github.com/fmtlib/fmt/issues/1524>, #1530 <https://github.com/fmtlib/fmt/pull/1530>, #1531 <https://github.com/fmtlib/fmt/issues/1531>, #1532 <https://github.com/fmtlib/fmt/pull/1532>, #1539 <https://github.com/fmtlib/fmt/issues/1539>, #1547 <https://github.com/fmtlib/fmt/issues/1547>, #1548 <https://github.com/fmtlib/fmt/issues/1548>, #1554 <https://github.com/fmtlib/fmt/pull/1554>, #1567 <https://github.com/fmtlib/fmt/issues/1567>, #1568 <https://github.com/fmtlib/fmt/pull/1568>, #1569 <https://github.com/fmtlib/fmt/pull/1569>, #1571 <https://github.com/fmtlib/fmt/pull/1571>, #1573 <https://github.com/fmtlib/fmt/pull/1573>, #1575 <https://github.com/fmtlib/fmt/pull/1575>, #1581 <https://github.com/fmtlib/fmt/pull/1581>, #1583 <https://github.com/fmtlib/fmt/issues/1583>, #1586 <https://github.com/fmtlib/fmt/issues/1586>, #1587 <https://github.com/fmtlib/fmt/issues/1587>, #1594 <https://github.com/fmtlib/fmt/issues/1594>, #1596 <https://github.com/fmtlib/fmt/pull/1596>, #1604 <https://github.com/fmtlib/fmt/issues/1604>, #1606 <https://github.com/fmtlib/fmt/pull/1606>, #1607 <https://github.com/fmtlib/fmt/issues/1607>, #1609 <https://github.com/fmtlib/fmt/issues/1609>). Thanks @marti4d (Chris Martin) <https://github.com/marti4d>, @iPherian <https://github.com/iPherian>, @parkertomatoes <https://github.com/parkertomatoes>, @gsjaardema (Greg Sjaardema) <https://github.com/gsjaardema>, @chronoxor (Ivan Shynkarenka) <https://github.com/chronoxor>, @DanielaE (Daniela Engert) <https://github.com/DanielaE>, @torsten48 <https://github.com/torsten48>, @tohammer (Tobias Hammer) <https://github.com/tohammer>, @lefticus (Jason Turner) <https://github.com/lefticus>, @ryusakki (Haise) <https://github.com/ryusakki>, @adnsv (Alex Denisov) <https://github.com/adnsv>, @fghzxm <https://github.com/fghzxm>, @refnum <https://github.com/refnum>, @pramodk (Pramod Kumbhar) <https://github.com/pramodk>, @Spirrwell <https://github.com/Spirrwell>, @scramsby (Scott Ramsby) <https://github.com/scramsby>_.