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
e29c2bc6
Commit
e29c2bc6
authored
Jun 30, 2022
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs
parent
c65e4286
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
doc/api.rst
doc/api.rst
+28
-8
No files found.
doc/api.rst
View file @
e29c2bc6
...
@@ -67,7 +67,7 @@ checked at compile time in C++20. To pass a runtime format string wrap it in
...
@@ -67,7 +67,7 @@ checked at compile time in C++20. To pass a runtime format string wrap it in
.. doxygenfunction:: print(std::FILE *f, format_string<T...> fmt, T&&... args)
.. doxygenfunction:: print(std::FILE *f, format_string<T...> fmt, T&&... args)
.. doxygenfunction:: vprint(std::FILE *f, string_view fmt, format_args args)
.. doxygenfunction:: vprint(std::FILE *f, string_view fmt, format_args args)
Compile-
t
ime Format String Checks
Compile-
T
ime Format String Checks
---------------------------------
---------------------------------
Compile-time checks are enabled when using ``FMT_STRING``. They support built-in
Compile-time checks are enabled when using ``FMT_STRING``. They support built-in
...
@@ -180,13 +180,13 @@ functions and locale support.
...
@@ -180,13 +180,13 @@ functions and locale support.
.. _udt:
.. _udt:
Formatting User-
d
efined Types
Formatting User-
D
efined Types
-----------------------------
-----------------------------
The {fmt} library provides formatters for many standard C++ types.
The {fmt} library provides formatters for many standard C++ types.
See :ref:`fmt/ranges.h <ranges-api>` for ranges and tuples including standard
See :ref:`fmt/ranges.h <ranges-api>` for ranges and tuples including standard
containers such as ``std::vector``, :ref:`fmt/chrono.h <chrono-api>` for date
containers such as ``std::vector``, :ref:`fmt/chrono.h <chrono-api>` for date
and time formatting and :ref:`fmt/std.h <std-api>` for
filesystem
and variant
and time formatting and :ref:`fmt/std.h <std-api>` for
path
and variant
formatting.
formatting.
To make a user-defined type formattable, specialize the ``formatter<T>`` struct
To make a user-defined type formattable, specialize the ``formatter<T>`` struct
...
@@ -308,7 +308,27 @@ If a type provides both a ``formatter`` specialization and an implicit
...
@@ -308,7 +308,27 @@ If a type provides both a ``formatter`` specialization and an implicit
conversion to a formattable type, the specialization takes precedence over the
conversion to a formattable type, the specialization takes precedence over the
conversion.
conversion.
Literal-based API
For scoped enums (enum classes) {fmt} also provides the ``format_as`` extension
API. To format an enum via this API define ``format_as`` that takes this enum
and converts it to the underlying type. ``format_as`` should be defined in the
same namespace as the enum.
Example (https://godbolt.org/z/r7vvGE1v7)::
#include <fmt/format.h>
namespace kevin_namespacy {
enum class film {
house_of_cards, american_beauty, se7en = 7
};
auto format_as(film f) { return fmt::underlying(f); }
}
int main() {
fmt::print("{}\n", kevin_namespacy::film::se7en); // prints "7"
}
Literal-Based API
-----------------
-----------------
The following user-defined literals are defined in ``fmt/format.h``.
The following user-defined literals are defined in ``fmt/format.h``.
...
@@ -387,8 +407,8 @@ non-default floating-point formatting that occasionally falls back on
...
@@ -387,8 +407,8 @@ non-default floating-point formatting that occasionally falls back on
.. _ranges-api:
.. _ranges-api:
Range
s
and Tuple Formatting
Range and Tuple Formatting
==========================
=
==========================
The library also supports convenient formatting of ranges and tuples::
The library also supports convenient formatting of ranges and tuples::
...
@@ -478,7 +498,7 @@ A ``std::variant`` is only formattable if every variant alternative is formattab
...
@@ -478,7 +498,7 @@ A ``std::variant`` is only formattable if every variant alternative is formattab
.. _compile-api:
.. _compile-api:
Format
string c
ompilation
Format
String C
ompilation
=========================
=========================
``fmt/compile.h`` provides format string compilation enabled via the
``fmt/compile.h`` provides format string compilation enabled via the
...
@@ -496,7 +516,7 @@ places where formatting is a performance bottleneck.
...
@@ -496,7 +516,7 @@ places where formatting is a performance bottleneck.
.. _color-api:
.. _color-api:
Terminal
color and text s
tyle
Terminal
Color and Text S
tyle
=============================
=============================
``fmt/color.h`` provides support for terminal color and text style output.
``fmt/color.h`` provides support for terminal color and text style output.
...
...
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