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
ef7369ce
Commit
ef7369ce
authored
Nov 28, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs
parent
40e4c227
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
32 deletions
+22
-32
README.rst
README.rst
+1
-1
doc/_templates/layout.html
doc/_templates/layout.html
+1
-1
doc/index.rst
doc/index.rst
+20
-30
No files found.
README.rst
View file @
ef7369ce
...
@@ -184,7 +184,7 @@ further details refer to the `source
...
@@ -184,7 +184,7 @@ further details refer to the `source
formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_)
formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_)
and as fast as `double-conversion <https://github.com/google/double-conversion>`_:
and as fast as `double-conversion <https://github.com/google/double-conversion>`_:
.. image:: https://user-images.githubusercontent.com/576385/
54883977-9fe8c000-4e28-11e9-8bde-272d122e7c52.jp
g
.. image:: https://user-images.githubusercontent.com/576385/
69767160-cdaca400-112f-11ea-9fc5-347c9f83caad.pn
g
:target: https://fmt.dev/unknown_mac64_clang10.0.html
:target: https://fmt.dev/unknown_mac64_clang10.0.html
Compile time and code bloat
Compile time and code bloat
...
...
doc/_templates/layout.html
View file @
ef7369ce
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
<div
class=
"jumbotron"
>
<div
class=
"jumbotron"
>
<div
class=
"tb-container"
>
<div
class=
"tb-container"
>
<h1>
{fmt}
</h1>
<h1>
{fmt}
</h1>
<p
class=
"lead"
>
Small, safe and fast
formatting library
</p>
<p
class=
"lead"
>
A modern
formatting library
</p>
<div
class=
"btn-group"
role=
"group"
>
<div
class=
"btn-group"
role=
"group"
>
{% set name = 'fmt' if version.split('.')[0]|int >= 3 else 'cppformat' %}
{% set name = 'fmt' if version.split('.')[0]|int >= 3 else 'cppformat' %}
<a
class=
"btn btn-success"
<a
class=
"btn btn-success"
...
...
doc/index.rst
View file @
ef7369ce
Overview
Overview
========
========
**
fmt** is an open-source formatting library.
**
{fmt}** is an open-source formatting library providing a fast and safe
It can be used as a fast and safe alternative to printf and IOS
treams.
alternative to C stdio and C++ ios
treams.
.. raw:: html
.. raw:: html
<div class="panel panel-default">
<div class="panel panel-default">
<div class="panel-heading">What users say:</div>
<div class="panel-heading">What users say:</div>
<div class="panel-body">
<div class="panel-body">
Thanks for creating this library. It’s been a hole in C++ for a long
Thanks for creating this library. It’s been a hole in C++ for
time. I’ve used both boost::format and loki::SPrintf, and neither felt
aa long time. I’ve used both <code>boost::format</code> and
like the right answer. This does.
<code>loki::SPrintf</code>, and neither felt like the right answer.
This does.
</div>
</div>
</div>
</div>
...
@@ -20,12 +21,13 @@ It can be used as a fast and safe alternative to printf and IOStreams.
...
@@ -20,12 +21,13 @@ It can be used as a fast and safe alternative to printf and IOStreams.
Format API
Format API
----------
----------
The replacement-based Format API provides a safe alternative to ``printf``,
The format API is similar in spirit to the C ``printf`` family of function but
``sprintf`` and friends with comparable or `better performance
is safer, simpler and serveral times `faster
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_
than common standard library implementations.
The `format string syntax <syntax.html>`_ is similar to the one used by
The `format string syntax <syntax.html>`_ is similar to the one used by
`str.format <http://docs.python.org/3/library/stdtypes.html#str.format>`_
`str.format <http://docs.python.org/3/library/stdtypes.html#str.format>`_
in
in
Python:
Python:
.. code:: c++
.. code:: c++
...
@@ -60,7 +62,7 @@ The Format API also supports positional arguments useful for localization:
...
@@ -60,7 +62,7 @@ The Format API also supports positional arguments useful for localization:
fmt::print("I'd rather be {1} than {0}.", "right", "happy");
fmt::print("I'd rather be {1} than {0}.", "right", "happy");
Named arguments can be created with ``fmt::arg``. This makes it easier to track
Named arguments can be created with ``fmt::arg``. This makes it easier to track
what goes where when multiple
values are being inser
ted:
what goes where when multiple
arguments are being format
ted:
.. code:: c++
.. code:: c++
...
@@ -72,21 +74,10 @@ an alternative, slightly terser syntax for named arguments:
...
@@ -72,21 +74,10 @@ an alternative, slightly terser syntax for named arguments:
.. code:: c++
.. code:: c++
using namespace fmt::literals;
fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.",
fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.",
"name"_a="World", "number"_a=42);
"name"_a="World", "number"_a=42);
The ``_format`` suffix may be used to format string literals similar to Python:
.. code:: c++
std::string message = "{0}{1}{0}"_format("abra", "cad");
Other than the placement of the format string on the left of the operator,
``_format`` is functionally identical to ``fmt::format``. In order to use the
literal operators, they must be made visible with the directive
``using namespace fmt::literals;``. Note that this brings in only ``_a`` and
``_format`` but nothing else from the ``fmt`` namespace.
.. _safety:
.. _safety:
Safety
Safety
...
@@ -106,11 +97,10 @@ string", because the argument ``"forty-two"`` is a string while the format code
...
@@ -106,11 +97,10 @@ string", because the argument ``"forty-two"`` is a string while the format code
.. code:: c++
.. code:: c++
format(
fmt
("The answer is {:d}"), "forty-two");
format(
FMT_STRING
("The answer is {:d}"), "forty-two");
reports a compile-time error for the same reason on compilers that support
reports a compile-time error for the same reason on compilers that support
relaxed ``constexpr``. See `here <api.html#c.fmt>`_ for how to enable
relaxed ``constexpr``. See `here <api.html#c.fmt>`_ for details.
compile-time checks.
The following code
The following code
...
@@ -178,13 +168,13 @@ The library is highly portable and relies only on a small set of C++11 features:
...
@@ -178,13 +168,13 @@ The library is highly portable and relies only on a small set of C++11 features:
* alias templates
* alias templates
These are available since GCC 4.8, Clang 3.0 and MSVC 19.0 (2015). For older
These are available since GCC 4.8, Clang 3.0 and MSVC 19.0 (2015). For older
compilers use
fmt
`version 4.x
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 and only requires C++98.
maintained and only requires C++98.
The output of all formatting functions is consistent across platforms. In
The output of all formatting functions is consistent across platforms. In
particular, formatting a floating-point infinity always gives ``inf`` while the
particular, formatting a floating-point infinity always gives ``inf`` while the
output of ``printf`` is platform-dependent
in this case
. For example,
output of ``printf`` is platform-dependent. For example,
.. code::
.. code::
...
@@ -197,9 +187,9 @@ always prints ``inf``.
...
@@ -197,9 +187,9 @@ always prints ``inf``.
Ease of Use
Ease of Use
-----------
-----------
fmt
has a small self-contained code base with the core library consisting of
{fmt}
has a small self-contained code base with the core library consisting of
just three header files and no external dependencies.
just three header files and no external dependencies.
A permissive
BSD
`license <https://github.com/fmtlib/fmt#license>`_ allows
A permissive
MIT
`license <https://github.com/fmtlib/fmt#license>`_ allows
using the library both in open-source and commercial projects.
using the library both in open-source and commercial projects.
.. raw:: html
.. raw:: html
...
...
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