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
4d366c68
Commit
4d366c68
authored
Nov 22, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:fmtlib/fmt
parents
3e1f70fe
6793ffc1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
32 deletions
+13
-32
README.rst
README.rst
+13
-32
No files found.
README.rst
View file @
4d366c68
...
@@ -81,16 +81,15 @@ Check a format string at compile time:
...
@@ -81,16 +81,15 @@ Check a format string at compile time:
.. code:: c++
.. code:: c++
// test.cc
// test.cc
#define FMT_STRING_ALIAS 1
#include <fmt/format.h>
#include <fmt/format.h>
std::string s = format(
fmt
("{2}"), 42);
std::string s = format(
FMT_STRING
("{2}"), 42);
.. code::
.. code::
$ c++ -Iinclude -std=c++14 test.cc
$ c++ -Iinclude -std=c++14 test.cc
...
...
test.cc:4:17: note: in instantiation of function template specialization 'fmt::v5::format<S, int>' requested here
test.cc:4:17: note: in instantiation of function template specialization 'fmt::v5::format<S, int>' requested here
std::string s = format(
fmt
("{2}"), 42);
std::string s = format(
FMT_STRING
("{2}"), 42);
^
^
include/fmt/core.h:778:19: note: non-constexpr function 'on_error' cannot be used in a constant expression
include/fmt/core.h:778:19: note: non-constexpr function 'on_error' cannot be used in a constant expression
ErrorHandler::on_error(message);
ErrorHandler::on_error(message);
...
@@ -122,11 +121,10 @@ Format objects of user-defined types via a simple `extension API
...
@@ -122,11 +121,10 @@ Format objects of user-defined types via a simple `extension API
template <>
template <>
struct fmt::formatter<date> {
struct fmt::formatter<date> {
template <typename ParseContext>
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template <typename FormatContext>
template <typename FormatContext>
auto format(const date
&d, FormatContext &
ctx) {
auto format(const date
& d, FormatContext&
ctx) {
return format_to(ctx.out(), "{}-{}-{}", d.year, d.month, d.day);
return format_to(ctx.out(), "{}-{}-{}", d.year, d.month, d.day);
}
}
};
};
...
@@ -142,12 +140,12 @@ which take arbitrary arguments (`godbolt <https://godbolt.org/g/MHjHVf>`_):
...
@@ -142,12 +140,12 @@ which take arbitrary arguments (`godbolt <https://godbolt.org/g/MHjHVf>`_):
.. code:: c++
.. code:: c++
// Prints formatted error message.
// Prints formatted error message.
void vreport_error(const char
*
format, fmt::format_args args) {
void vreport_error(const char
*
format, fmt::format_args args) {
fmt::print("Error: ");
fmt::print("Error: ");
fmt::vprint(format, args);
fmt::vprint(format, args);
}
}
template <typename... Args>
template <typename... Args>
void report_error(const char
*
format, const Args & ... args) {
void report_error(const char
*
format, const Args & ... args) {
vreport_error(format, fmt::make_format_args(args...));
vreport_error(format, fmt::make_format_args(args...));
}
}
...
@@ -166,15 +164,14 @@ Speed tests
...
@@ -166,15 +164,14 @@ Speed tests
================= ============= ===========
================= ============= ===========
Library Method Run Time, s
Library Method Run Time, s
================= ============= ===========
================= ============= ===========
libc printf 1.01
libc printf 1.03
libc++ std::ostream 3.04
libc++ std::ostream 2.98
{fmt} 1632f72 fmt::print 0.86
{fmt} 4de41a fmt::print 0.76
tinyformat 2.0.1 tfm::printf 3.23
Boost Format 1.67 boost::format 7.24
Boost Format 1.67 boost::format 7.98
Folly Format folly::format 2.23
Folly Format folly::format 2.23
================= ============= ===========
================= ============= ===========
{fmt} is the fastest of the benchmarked methods, ~
17
% faster than ``printf``.
{fmt} is the fastest of the benchmarked methods, ~
35
% faster than ``printf``.
The above results were generated by building ``tinyformat_test.cpp`` on macOS
The above results were generated by building ``tinyformat_test.cpp`` on macOS
10.14.3 with ``clang++ -O3 -DSPEED_TEST -DHAVE_FORMAT``, and taking the best of
10.14.3 with ``clang++ -O3 -DSPEED_TEST -DHAVE_FORMAT``, and taking the best of
...
@@ -211,7 +208,6 @@ printf 2.6 29 26
...
@@ -211,7 +208,6 @@ printf 2.6 29 26
printf+string 16.4 29 26
printf+string 16.4 29 26
iostreams 31.1 59 55
iostreams 31.1 59 55
{fmt} 19.0 37 34
{fmt} 19.0 37 34
tinyformat 44.0 103 97
Boost Format 91.9 226 203
Boost Format 91.9 226 203
Folly Format 115.7 101 88
Folly Format 115.7 101 88
============= =============== ==================== ==================
============= =============== ==================== ==================
...
@@ -232,14 +228,13 @@ printf 2.2 33 30
...
@@ -232,14 +228,13 @@ printf 2.2 33 30
printf+string 16.0 33 30
printf+string 16.0 33 30
iostreams 28.3 56 52
iostreams 28.3 56 52
{fmt} 18.2 59 50
{fmt} 18.2 59 50
tinyformat 32.6 88 82
Boost Format 54.1 365 303
Boost Format 54.1 365 303
Folly Format 79.9 445 430
Folly Format 79.9 445 430
============= =============== ==================== ==================
============= =============== ==================== ==================
``libc``, ``lib(std)c++`` and ``libfmt`` are all linked as shared libraries to
``libc``, ``lib(std)c++`` and ``libfmt`` are all linked as shared libraries to
compare formatting function overhead only. Boost Format
and tinyformat are
compare formatting function overhead only. Boost Format
is a
header-only librar
ies so they do
n't provide any linkage options.
header-only librar
y so it does
n't provide any linkage options.
Running the tests
Running the tests
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
...
@@ -425,20 +420,6 @@ arguments. However it has significant limitations, citing its author:
...
@@ -425,20 +420,6 @@ arguments. However it has significant limitations, citing its author:
It is also quite big and has a heavy dependency, STLSoft, which might be
It is also quite big and has a heavy dependency, STLSoft, which might be
too restrictive for using it in some projects.
too restrictive for using it in some projects.
Loki SafeFormat
~~~~~~~~~~~~~~~
SafeFormat is a formatting library which uses ``printf``-like format strings and
is type safe. It doesn't support user-defined types or positional arguments and
makes unconventional use of ``operator()`` for passing format arguments.
Tinyformat
~~~~~~~~~~
This library supports ``printf``-like format strings and is very small .
It doesn't support positional arguments and wrapping it in C++98 is somewhat
difficult. Tinyformat relies on iostreams which limits its performance.
Boost Spirit.Karma
Boost Spirit.Karma
~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
...
...
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