C++ Format v3.0.0 Release Notes

Release Date: 2016-05-07 // over 6 years ago
    • The project has been renamed from C++ Format (cppformat) to fmt for consistency with the used namespace and macro prefix (#307 <https://github.com/fmtlib/fmt/issues/307>_). Library headers are now located in the fmt directory:

    .. code:: c++

    #include "fmt/format.h"
    

    Including format.h from the cppformat directory is deprecated but works via a proxy header which will be removed in the next major version.

    The documentation is now available at https://fmt.dev.

    • โž• Added support for strftime <http://en.cppreference.com/w/cpp/chrono/c/strftime>-like date and time formatting <https://fmt.dev/3.0.0/api.html#date-and-time-formatting> (#283 <https://github.com/fmtlib/fmt/issues/283>_):

    .. code:: c++

    #include "fmt/time.h"
    
    std::time_t t = std::time(nullptr);
    // Prints "The date is 2016-04-29." (with the current date)
    fmt::print("The date is {:%Y-%m-%d}.", *std::localtime(&t));
    
    • ๐Ÿ‘ std::ostream support including formatting of user-defined types that provide overloaded operator<< has been moved to fmt/ostream.h:

    .. code:: c++

    #include "fmt/ostream.h"
    
    class Date {
      int year_, month_, day_;
    public:
      Date(int year, int month, int day) : year_(year), month_(month), day_(day) {}
    
      friend std::ostream &operator<<(std::ostream &os, const Date &d) {
        return os << d.year_ << '-' << d.month_ << '-' << d.day_;
      }
    };
    
    std::string s = fmt::format("The date is {}", Date(2012, 12, 9));
    // s == "The date is 2012-12-9"
    
    • โž• Added support for custom argument formatters <https://fmt.dev/3.0.0/api.html#argument-formatters>_ (#235 <https://github.com/fmtlib/fmt/issues/235>_).

    • โž• Added support for locale-specific integer formatting with the n specifier (#305 <https://github.com/fmtlib/fmt/issues/305>_):

    .. code:: c++

    std::setlocale(LC_ALL, "en_US.utf8");
    fmt::print("cppformat: {:n}\n", 1234567); // prints 1,234,567
    
    • ๐Ÿ–จ Sign is now preserved when formatting an integer with an incorrect printf format specifier (#265 <https://github.com/fmtlib/fmt/issues/265>_):

    .. code:: c++

    fmt::printf("%lld", -42); // prints -42
    

    Note that it would be an undefined behavior in std::printf.

    • ๐Ÿ–จ Length modifiers such as ll are now optional in printf formatting functions and the correct type is determined automatically (#255 <https://github.com/fmtlib/fmt/issues/255>_):

    .. code:: c++

    fmt::printf("%d", std::numeric_limits<long long>::max());
    

    Note that it would be an undefined behavior in std::printf.

    • โž• Added initial support for custom formatters (#231 <https://github.com/fmtlib/fmt/issues/231>_).

    • ๐Ÿ›  Fixed detection of user-defined literal support on Intel C++ compiler (#311 <https://github.com/fmtlib/fmt/issues/311>, #312 <https://github.com/fmtlib/fmt/pull/312>). Thanks to @dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>_ and @speth (Ray Speth) <https://github.com/speth>_.

    • โฌ‡๏ธ Reduced compile time (#243 <https://github.com/fmtlib/fmt/pull/243>, #249 <https://github.com/fmtlib/fmt/pull/249>, #317 <https://github.com/fmtlib/fmt/issues/317>_):

    .. image:: https://cloud.githubusercontent.com/assets/4831417/11614060/ b9e826d2-9c36-11e5-8666-d4131bf503ef.png

    .. image:: https://cloud.githubusercontent.com/assets/4831417/11614080/ 6ac903cc-9c37-11e5-8165-26df6efae364.png

    Thanks to @dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>_.

    • โœ… Compile test fixes (#313 <https://github.com/fmtlib/fmt/pull/313>). Thanks to @dean0x7d (Dean Moldovan) <https://github.com/dean0x7d>.

    • ๐Ÿ“š Documentation fixes (#239 <https://github.com/fmtlib/fmt/pull/239>, #248 <https://github.com/fmtlib/fmt/issues/248>, #252 <https://github.com/fmtlib/fmt/issues/252>, #258 <https://github.com/fmtlib/fmt/pull/258>, #260 <https://github.com/fmtlib/fmt/issues/260>, #301 <https://github.com/fmtlib/fmt/issues/301>, #309 <https://github.com/fmtlib/fmt/pull/309>). Thanks to @ReadmeCritic <https://github.com/ReadmeCritic> @Gachapen (Magnus Bjerke Vik) <https://github.com/Gachapen>_ and @jwilk (Jakub Wilk) <https://github.com/jwilk>_.

    • ๐Ÿ›  Fixed compiler and sanitizer warnings (#244 <https://github.com/fmtlib/fmt/issues/244>, #256 <https://github.com/fmtlib/fmt/pull/256>, #259 <https://github.com/fmtlib/fmt/pull/259>, #263 <https://github.com/fmtlib/fmt/issues/263>, #274 <https://github.com/fmtlib/fmt/issues/274>, #277 <https://github.com/fmtlib/fmt/pull/277>, #286 <https://github.com/fmtlib/fmt/pull/286>, #291 <https://github.com/fmtlib/fmt/issues/291>, #296 <https://github.com/fmtlib/fmt/issues/296>, #308 <https://github.com/fmtlib/fmt/issues/308>) Thanks to @mwinterb <https://github.com/mwinterb>, @pweiskircher (Patrik Weiskircher) <https://github.com/pweiskircher>, @Naios <https://github.com/Naios>_.

    • ๐Ÿ‘Œ Improved compatibility with Windows Store apps (#280 <https://github.com/fmtlib/fmt/issues/280>, #285 <https://github.com/fmtlib/fmt/pull/285>) Thanks to @mwinterb <https://github.com/mwinterb>_.

    • โž• Added tests of compatibility with older C++ standards (#273 <https://github.com/fmtlib/fmt/pull/273>). Thanks to @niosHD <https://github.com/niosHD>.

    • ๐Ÿ›  Fixed Android build (#271 <https://github.com/fmtlib/fmt/pull/271>). Thanks to @newnon <https://github.com/newnon>.

    • ๐Ÿ”„ Changed ArgMap to be backed by a vector instead of a map. (#261 <https://github.com/fmtlib/fmt/issues/261>, #262 <https://github.com/fmtlib/fmt/pull/262>). Thanks to @mwinterb <https://github.com/mwinterb>_.

    • โž• Added fprintf overload that writes to a std::ostream (#251 <https://github.com/fmtlib/fmt/pull/251>). Thanks to nickhutchinson (Nicholas Hutchinson) <https://github.com/nickhutchinson>.

    • ๐Ÿ Export symbols when building a Windows DLL (#245 <https://github.com/fmtlib/fmt/pull/245>). Thanks to macdems (Maciek Dems) <https://github.com/macdems>.

    • ๐Ÿ›  Fixed compilation on Cygwin (#304 <https://github.com/fmtlib/fmt/issues/304>_).

    • โ†ช Implemented a workaround for a bug in Apple LLVM version 4.2 of clang (#276 <https://github.com/fmtlib/fmt/issues/276>_).

    • โœ… Implemented a workaround for Google Test bug #705 <https://github.com/google/googletest/issues/705>_ on gcc 6 (#268 <https://github.com/fmtlib/fmt/issues/268>). Thanks to octoploid <https://github.com/octoploid>.

    • โœ‚ Removed Biicode support because the latter has been discontinued.