Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
78677e3f
Commit
78677e3f
authored
May 13, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ChangeLog and docs
parent
ad23270e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
20 deletions
+84
-20
ChangeLog.rst
ChangeLog.rst
+47
-10
doc/index.rst
doc/index.rst
+37
-10
No files found.
ChangeLog.rst
View file @
78677e3f
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 @@
...
@@ -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 @@
...
@@ -41,15 +43,27 @@
};
};
}
}
std::string s = f
mt::f
ormat(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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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
------------------
------------------
...
...
doc/index.rst
View file @
78677e3f
...
@@ -33,13 +33,13 @@ in Python:
...
@@ -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::
MemoryWrit
er`` to avoid constructing ``std::string``:
``fmt::
memory_buff
er`` 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
...
@@ -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
...
@@ -106,7 +101,7 @@ the code
fmt::format("The answer is {:d}", "forty-two");
fmt::format("The answer is {:d}", "forty-two");
throws a ``
FormatE
rror`` exception with description
throws a ``
format_e
rror`` 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
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment