mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-29 21:31:05 +00:00
Update ChangeLog and docs
This commit is contained in:
parent
ad23270ec7
commit
78677e3fcf
@ -1,18 +1,21 @@
|
|||||||
5.0.0 - TBD
|
5.0.0 - TBD
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
* Added a requirement for compiler support for variadic templates and dropped
|
* Added a requirement for partial C++11 support, most importantly variadic
|
||||||
``FMT_VARIADIC_*`` emulation macros. Variadic templates are available since
|
templates and type traits, and dropped ``FMT_VARIADIC_*`` emulation macros.
|
||||||
GCC 4.4, Clang 2.9 and MSVC 18.0 (2013). For older compilers use `version 4.x
|
Variadic templates are available since GCC 4.4, Clang 2.9 and MSVC 18.0 (2013).
|
||||||
|
For older compilers use {fmt} `version 4.x
|
||||||
<https://github.com/fmtlib/fmt/releases/tag/4.1.0>`_ which continues to be
|
<https://github.com/fmtlib/fmt/releases/tag/4.1.0>`_ which continues to be
|
||||||
maintained.
|
maintained and works with C++98 compilers.
|
||||||
|
|
||||||
* Renamed symbols to follow standard C++ naming conventions and proposed a subset
|
* Renamed symbols to follow standard C++ naming conventions and proposed a subset
|
||||||
of the library for standardization in `P0645R2 Text Formatting
|
of the library for standardization in `P0645R2 Text Formatting
|
||||||
<https://wg21.link/P0645>`_.
|
<https://wg21.link/P0645>`_.
|
||||||
|
|
||||||
* Swparated format string parsing and formatting in the extension API to enable
|
* Implemented ``constexpr`` parsing of format strings.
|
||||||
compile-time format-string processing. For example
|
|
||||||
|
* Separated format string parsing and formatting in the extension API to enable
|
||||||
|
compile-time format string processing. For example
|
||||||
|
|
||||||
.. code:: c++
|
.. code:: c++
|
||||||
|
|
||||||
@ -26,8 +29,7 @@
|
|||||||
spec = *it;
|
spec = *it;
|
||||||
if (spec != 'd' && spec != 's')
|
if (spec != 'd' && spec != 's')
|
||||||
throw format_error("invalid specifier");
|
throw format_error("invalid specifier");
|
||||||
++it;
|
return ++it;
|
||||||
return it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
@ -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
|
will give a compile-time error due to invalid format specifier (`godbolt
|
||||||
<https://godbolt.org/g/9s4kNB>`_)::
|
<https://godbolt.org/g/ywhrPp>`_)::
|
||||||
|
|
||||||
...
|
...
|
||||||
<source>:12:45: error: expression '<throw-expression>' is not a constant expression
|
<source>:12:45: error: expression '<throw-expression>' is not a constant expression
|
||||||
throw format_error("invalid specifier");
|
throw format_error("invalid specifier");
|
||||||
|
|
||||||
|
* Improved compile times by reducing dependencies on standard headers and
|
||||||
|
providing a lightweight `core API <http://fmtlib.net/dev/api.html#core-api>`_:
|
||||||
|
|
||||||
|
.. code:: c++
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
|
fmt::print("The answer is {}.", 42);
|
||||||
|
|
||||||
|
See `Compile time and code bloat
|
||||||
|
<https://github.com/fmtlib/fmt#compile-time-and-code-bloat>`_.
|
||||||
|
|
||||||
* Added the `make_format_args
|
* Added the `make_format_args
|
||||||
<http://fmtlib.net/dev/api.html#_CPPv2N3fmt16make_format_argsEDpRK4Args>`_
|
<http://fmtlib.net/dev/api.html#_CPPv2N3fmt16make_format_argsEDpRK4Args>`_
|
||||||
function for capturing formatting arguments:
|
function for capturing formatting arguments:
|
||||||
@ -80,10 +94,19 @@
|
|||||||
in the format API and provided ``fmt::string_view`` which implements a subset
|
in the format API and provided ``fmt::string_view`` which implements a subset
|
||||||
of ``std::string_view`` API for pre-C++17 systems.
|
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
|
* Removed the write API in favor of the `format API
|
||||||
<http://fmtlib.net/dev/api.html#format-api>`_ with compile-time handling of
|
<http://fmtlib.net/dev/api.html#format-api>`_ with compile-time handling of
|
||||||
format strings.
|
format strings.
|
||||||
|
|
||||||
|
* Disallowed formatting of multibyte strings into a wide character target
|
||||||
|
(`#606 <https://github.com/fmtlib/fmt/pull/606>`_).
|
||||||
|
|
||||||
* Added a section on `formatting user-defined types
|
* Added a section on `formatting user-defined types
|
||||||
<http://fmtlib.net/dev/api.html#formatting-user-defined-types>`_ to the docs
|
<http://fmtlib.net/dev/api.html#formatting-user-defined-types>`_ to the docs
|
||||||
(`#393 <https://github.com/fmtlib/fmt/pull/393>`_).
|
(`#393 <https://github.com/fmtlib/fmt/pull/393>`_).
|
||||||
@ -94,6 +117,12 @@
|
|||||||
(`#515 <https://github.com/fmtlib/fmt/pull/515>`_).
|
(`#515 <https://github.com/fmtlib/fmt/pull/515>`_).
|
||||||
Thanks `@ibell (Ian Bell) <https://github.com/ibell>`_.
|
Thanks `@ibell (Ian Bell) <https://github.com/ibell>`_.
|
||||||
|
|
||||||
|
* Added a `note about errno <http://fmtlib.net/latest/index.html#safety>`_ to the
|
||||||
|
documentation (
|
||||||
|
`#614 <https://github.com/fmtlib/fmt/issues/614>`_,
|
||||||
|
`#617 <https://github.com/fmtlib/fmt/pull/617>`_).
|
||||||
|
Thanks `@mihaitodor (Mihai Todor) <https://github.com/mihaitodor>`_.
|
||||||
|
|
||||||
* Implemented thread-safe time formatting (
|
* Implemented thread-safe time formatting (
|
||||||
`#395 <https://github.com/fmtlib/fmt/issues/395>`_,
|
`#395 <https://github.com/fmtlib/fmt/issues/395>`_,
|
||||||
`#396 <https://github.com/fmtlib/fmt/pull/396>`_).
|
`#396 <https://github.com/fmtlib/fmt/pull/396>`_).
|
||||||
@ -163,6 +192,10 @@
|
|||||||
* Fixed a name conflict with Xlib
|
* Fixed a name conflict with Xlib
|
||||||
(`#483 <https://github.com/fmtlib/fmt/issues/483>`_).
|
(`#483 <https://github.com/fmtlib/fmt/issues/483>`_).
|
||||||
|
|
||||||
|
* Fixed a name conflict with the macro ``CHAR_WIDTH`` in glibc
|
||||||
|
(`#616 <https://github.com/fmtlib/fmt/pull/616>`_).
|
||||||
|
Thanks `@aroig (Abdó Roig-Maranges) <https://github.com/aroig>`_.
|
||||||
|
|
||||||
* Fixed signbit detection (`#423 <https://github.com/fmtlib/fmt/pull/423>`_).
|
* Fixed signbit detection (`#423 <https://github.com/fmtlib/fmt/pull/423>`_).
|
||||||
|
|
||||||
* Fixed missing intrinsic when included from C++/CLI
|
* Fixed missing intrinsic when included from C++/CLI
|
||||||
@ -181,6 +214,10 @@
|
|||||||
(`#469 <https://github.com/fmtlib/fmt/pull/469>`_).
|
(`#469 <https://github.com/fmtlib/fmt/pull/469>`_).
|
||||||
Thanks `@richardeakin (Richard Eakin) <https://github.com/richardeakin>`_.
|
Thanks `@richardeakin (Richard Eakin) <https://github.com/richardeakin>`_.
|
||||||
|
|
||||||
|
* Added a missing ``inline`` in the header-only mode
|
||||||
|
(`#626 <https://github.com/fmtlib/fmt/pull/626>`_).
|
||||||
|
Thanks `@aroig (Abdó Roig-Maranges) <https://github.com/aroig>`_.
|
||||||
|
|
||||||
4.1.0 - 2017-12-20
|
4.1.0 - 2017-12-20
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@ in Python:
|
|||||||
fmt::format("The answer is {}", 42);
|
fmt::format("The answer is {}", 42);
|
||||||
|
|
||||||
The ``fmt::format`` function returns a string "The answer is 42". You can use
|
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++
|
.. code:: c++
|
||||||
|
|
||||||
fmt::MemoryWriter w;
|
fmt::memory_buffer out;
|
||||||
w.write("Look, a {} string", 'C');
|
format_to(out, "For a moment, {} happened.", "nothing");
|
||||||
w.c_str(); // returns a C string (const char*)
|
out.data(); // returns a pointer to the formatted data
|
||||||
|
|
||||||
The ``fmt::print`` function performs formatting and writes the result to a file:
|
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");
|
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:
|
The Format API also supports positional arguments useful for localization:
|
||||||
|
|
||||||
.. code:: c++
|
.. code:: c++
|
||||||
@ -106,7 +101,7 @@ the code
|
|||||||
|
|
||||||
fmt::format("The answer is {:d}", "forty-two");
|
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
|
"unknown format code 'd' for string", because the argument
|
||||||
``"forty-two"`` is a string while the format code ``d``
|
``"forty-two"`` is a string while the format code ``d``
|
||||||
only applies to integers.
|
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
|
any assumptions about it and always set it to ``0`` before making any system
|
||||||
calls that convey error information via ``errno``.
|
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 <https://godbolt.org/g/TZU4KF>`_),
|
||||||
|
|
||||||
|
.. code:: c++
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
|
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<char>, fmt::v5::format_args)
|
||||||
|
xor eax, eax
|
||||||
|
add rsp, 24
|
||||||
|
ret
|
||||||
|
.L.str:
|
||||||
|
.asciz "The answer is {}."
|
||||||
|
|
||||||
.. _portability:
|
.. _portability:
|
||||||
|
|
||||||
Portability
|
Portability
|
||||||
|
Loading…
Reference in New Issue
Block a user