C++ Format v4.0.0 Release Notes

Release Date: 2017-06-27 // almost 7 years ago
    • โœ‚ Removed old compatibility headers cppformat/*.h and CMake options (#527 <https://github.com/fmtlib/fmt/pull/527>). Thanks @maddinat0r (Alex Martin) <https://github.com/maddinat0r>.

    • โž• Added string.h containing fmt::to_string() as alternative to std::to_string() as well as other string writer functionality (#326 <https://github.com/fmtlib/fmt/issues/326>_ and #441 <https://github.com/fmtlib/fmt/pull/441>_):

    .. code:: c++

    #include "fmt/string.h"
    
    std::string answer = fmt::to_string(42);
    

    Thanks to @glebov-andrey (Andrey Glebov) <https://github.com/glebov-andrey>_.

    • ๐Ÿšš Moved fmt::printf() to new printf.h header and allowed %s as generic specifier (#453 <https://github.com/fmtlib/fmt/pull/453>), made %.f more conformant to regular printf() (#490 <https://github.com/fmtlib/fmt/pull/490>), added custom writer support (#476 <https://github.com/fmtlib/fmt/issues/476>) and implemented missing custom argument formatting (#339 <https://github.com/fmtlib/fmt/pull/339> and #340 <https://github.com/fmtlib/fmt/pull/340>_):

    .. code:: c++

    #include "fmt/printf.h"
    
    // %s format specifier can be used with any argument type.
    fmt::printf("%s", 42);
    

    Thanks @mojoBrendan <https://github.com/mojoBrendan>, @manylegged (Arthur Danskin) <https://github.com/manylegged> and @spacemoose (Glen Stark) <https://github.com/spacemoose>. See also #360 <https://github.com/fmtlib/fmt/issues/360>, #335 <https://github.com/fmtlib/fmt/issues/335>_ and #331 <https://github.com/fmtlib/fmt/issues/331>_.

    • โž• Added container.h containing a BasicContainerWriter to write to containers like std::vector (#450 <https://github.com/fmtlib/fmt/pull/450>). Thanks @polyvertex (Jean-Charles Lefebvre) <https://github.com/polyvertex>.

    • โž• Added fmt::join() function that takes a range and formats its elements separated by a given string (#466 <https://github.com/fmtlib/fmt/pull/466>_):

    .. code:: c++

    #include "fmt/format.h"
    
    std::vector<double> v = {1.2, 3.4, 5.6};
    // Prints "(+01.20, +03.40, +05.60)".
    fmt::print("({:+06.2f})", fmt::join(v.begin(), v.end(), ", "));
    

    Thanks @olivier80 <https://github.com/olivier80>_.

    • โž• Added support for custom formatting specifications to simplify customization of built-in formatting (#444 <https://github.com/fmtlib/fmt/pull/444>). Thanks @polyvertex (Jean-Charles Lefebvre) <https://github.com/polyvertex>. See also #439 <https://github.com/fmtlib/fmt/issues/439>_.

    • Added fmt::format_system_error() for error code formatting (#323 <https://github.com/fmtlib/fmt/issues/323>_ and #526 <https://github.com/fmtlib/fmt/pull/526>). Thanks @maddinat0r (Alex Martin) <https://github.com/maddinat0r>.

    • โž• Added thread-safe fmt::localtime() and fmt::gmtime() as replacement for the standard version to time.h (#396 <https://github.com/fmtlib/fmt/pull/396>). Thanks @codicodi <https://github.com/codicodi>.

    • Internal improvements to NamedArg and ArgLists (#389 <https://github.com/fmtlib/fmt/pull/389>_ and #390 <https://github.com/fmtlib/fmt/pull/390>). Thanks @chronoxor <https://github.com/chronoxor>.

    • ๐Ÿ›  Fixed crash due to bug in FormatBuf (#493 <https://github.com/fmtlib/fmt/pull/493>). Thanks @effzeh <https://github.com/effzeh>. See also #480 <https://github.com/fmtlib/fmt/issues/480>_ and #491 <https://github.com/fmtlib/fmt/issues/491>_.

    • ๐Ÿ›  Fixed handling of wide strings in fmt::StringWriter.

    • ๐Ÿ‘Œ Improved compiler error messages (#357 <https://github.com/fmtlib/fmt/issues/357>_).

    • ๐Ÿ›  Fixed various warnings and issues with various compilers (#494 <https://github.com/fmtlib/fmt/pull/494>, #499 <https://github.com/fmtlib/fmt/pull/499>, #483 <https://github.com/fmtlib/fmt/pull/483>, #485 <https://github.com/fmtlib/fmt/pull/485>, #482 <https://github.com/fmtlib/fmt/pull/482>, #475 <https://github.com/fmtlib/fmt/pull/475>, #473 <https://github.com/fmtlib/fmt/pull/473>_ and #414 <https://github.com/fmtlib/fmt/pull/414>). Thanks @chronoxor <https://github.com/chronoxor>, @zhaohuaxishi <https://github.com/zhaohuaxishi>, @pkestene (Pierre Kestener) <https://github.com/pkestene>, @dschmidt (Dominik Schmidt) <https://github.com/dschmidt>_ and @0x414c (Alexey Gorishny) <https://github.com/0x414c>_ .

    • ๐Ÿ‘Œ Improved CMake: targets are now namespaced (#511 <https://github.com/fmtlib/fmt/pull/511>_ and #513 <https://github.com/fmtlib/fmt/pull/513>), supported header-only printf.h (#354 <https://github.com/fmtlib/fmt/pull/354>), fixed issue with minimal supported library subset (#418 <https://github.com/fmtlib/fmt/issues/418>, #419 <https://github.com/fmtlib/fmt/pull/419> and #420 <https://github.com/fmtlib/fmt/pull/420>). Thanks @bjoernthiel (Bjoern Thiel) <https://github.com/bjoernthiel>, @niosHD (Mario Werner) <https://github.com/niosHD>, @LogicalKnight (Sean LK) <https://github.com/LogicalKnight> and @alabuzhev (Alex Alabuzhev) <https://github.com/alabuzhev>_.

    • ๐Ÿ‘Œ Improved documentation. Thanks to @pwm1234 (Phil) <https://github.com/pwm1234>_ for #393 <https://github.com/fmtlib/fmt/pull/393>_.