diff --git a/ChangeLog.rst b/ChangeLog.rst index 5fa7b9c5..d3fd26da 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,18 +1,21 @@ 5.0.0 - TBD ----------- -* Added a requirement for compiler support for variadic templates and dropped - ``FMT_VARIADIC_*`` emulation macros. Variadic templates are available since - GCC 4.4, Clang 2.9 and MSVC 18.0 (2013). For older compilers use `version 4.x +* Added a requirement for partial C++11 support, most importantly variadic + templates and type traits, and dropped ``FMT_VARIADIC_*`` emulation macros. + Variadic templates are available since GCC 4.4, Clang 2.9 and MSVC 18.0 (2013). + For older compilers use {fmt} `version 4.x `_ which continues to be - maintained. + maintained and works with C++98 compilers. * Renamed symbols to follow standard C++ naming conventions and proposed a subset of the library for standardization in `P0645R2 Text Formatting `_. -* Swparated format string parsing and formatting in the extension API to enable - compile-time format-string processing. For example +* Implemented ``constexpr`` parsing of format strings. + +* Separated format string parsing and formatting in the extension API to enable + compile-time format string processing. For example .. code:: c++ @@ -26,8 +29,7 @@ spec = *it; if (spec != 'd' && spec != 's') throw format_error("invalid specifier"); - ++it; - return it; + return ++it; } template @@ -41,15 +43,27 @@ }; } - std::string s = fmt::format(fmt("{:x}"), S()); + std::string s = format(fmt("{:x}"), S()); will give a compile-time error due to invalid format specifier (`godbolt - `_):: + `_):: ... :12:45: error: expression '' is not a constant expression throw format_error("invalid specifier"); +* Improved compile times by reducing dependencies on standard headers and + providing a lightweight `core API `_: + + .. code:: c++ + + #include + + fmt::print("The answer is {}.", 42); + + See `Compile time and code bloat + `_. + * Added the `make_format_args `_ function for capturing formatting arguments: @@ -80,10 +94,19 @@ in the format API and provided ``fmt::string_view`` which implements a subset of ``std::string_view`` API for pre-C++17 systems. +* Allowed mixing named and automatic arguments: + + .. code:: c++ + + fmt::format("{} {two}", 1, fmt::arg("two", 2)); + * Removed the write API in favor of the `format API `_ with compile-time handling of format strings. +* Disallowed formatting of multibyte strings into a wide character target + (`#606 `_). + * Added a section on `formatting user-defined types `_ to the docs (`#393 `_). @@ -94,6 +117,12 @@ (`#515 `_). Thanks `@ibell (Ian Bell) `_. +* Added a `note about errno `_ to the + documentation ( + `#614 `_, + `#617 `_). + Thanks `@mihaitodor (Mihai Todor) `_. + * Implemented thread-safe time formatting ( `#395 `_, `#396 `_). @@ -163,6 +192,10 @@ * Fixed a name conflict with Xlib (`#483 `_). +* Fixed a name conflict with the macro ``CHAR_WIDTH`` in glibc + (`#616 `_). + Thanks `@aroig (Abdó Roig-Maranges) `_. + * Fixed signbit detection (`#423 `_). * Fixed missing intrinsic when included from C++/CLI @@ -181,6 +214,10 @@ (`#469 `_). Thanks `@richardeakin (Richard Eakin) `_. +* Added a missing ``inline`` in the header-only mode + (`#626 `_). + Thanks `@aroig (Abdó Roig-Maranges) `_. + 4.1.0 - 2017-12-20 ------------------ diff --git a/doc/index.rst b/doc/index.rst index fa5701a4..ac463062 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -33,13 +33,13 @@ in Python: fmt::format("The answer is {}", 42); The ``fmt::format`` function returns a string "The answer is 42". You can use -``fmt::MemoryWriter`` to avoid constructing ``std::string``: +``fmt::memory_buffer`` to avoid constructing ``std::string``: .. code:: c++ - fmt::MemoryWriter w; - w.write("Look, a {} string", 'C'); - w.c_str(); // returns a C string (const char*) + fmt::memory_buffer out; + format_to(out, "For a moment, {} happened.", "nothing"); + out.data(); // returns a pointer to the formatted data The ``fmt::print`` function performs formatting and writes the result to a file: @@ -54,11 +54,6 @@ The file argument can be omitted in which case the function prints to fmt::print("Don't {}\n", "panic"); -If your compiler supports C++11, then the formatting functions are implemented -with variadic templates. Otherwise variadic functions are emulated by generating -a set of lightweight wrappers. This ensures compatibility with older compilers -while providing a natural API. - The Format API also supports positional arguments useful for localization: .. code:: c++ @@ -106,7 +101,7 @@ the code fmt::format("The answer is {:d}", "forty-two"); -throws a ``FormatError`` exception with description +throws a ``format_error`` exception with description "unknown format code 'd' for string", because the argument ``"forty-two"`` is a string while the format code ``d`` only applies to integers. @@ -135,6 +130,38 @@ fmt does not attempt to preserve the value of ``errno``, users should not make any assumptions about it and always set it to ``0`` before making any system calls that convey error information via ``errno``. +Compact binary code +------------------- + +Each call to a formatting function results in a compact binary code. For example +(`godbolt `_), + +.. code:: c++ + + #include + + int main() { + fmt::print("The answer is {}.", 42); + } + +compiles to just + +.. code:: asm + + main: # @main + sub rsp, 24 + mov qword ptr [rsp], 42 + mov rcx, rsp + mov edi, offset .L.str + mov esi, 17 + mov edx, 2 + call fmt::v5::vprint(fmt::v5::basic_string_view, fmt::v5::format_args) + xor eax, eax + add rsp, 24 + ret + .L.str: + .asciz "The answer is {}." + .. _portability: Portability