mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 02:29:08 +00:00
Update docs
This commit is contained in:
parent
e9fa42acb8
commit
f3f19e762f
@ -42,8 +42,8 @@ Features
|
||||
performance of IOStreams. See `Speed tests`_ and
|
||||
`Fast integer to string conversion in C++
|
||||
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
|
||||
* Small code size both in terms of source code (the core library consists of a
|
||||
single header file and a single source file) and compiled code.
|
||||
* Small code size both in terms of source code (the core library consists of two
|
||||
header files and a single source file) and compiled code.
|
||||
See `Compile time and code bloat`_.
|
||||
* Reliability: the library has an extensive set of `unit tests
|
||||
<https://github.com/fmtlib/fmt/tree/master/test>`_.
|
||||
@ -101,7 +101,7 @@ Format strings can be checked at compile time:
|
||||
on_error("argument index out of range");
|
||||
^
|
||||
|
||||
fmt can be used as a safe portable replacement for ``itoa``:
|
||||
{fmt} can be used as a safe portable replacement for ``itoa``:
|
||||
|
||||
.. code:: c++
|
||||
|
||||
|
20
doc/api.rst
20
doc/api.rst
@ -11,7 +11,7 @@ namespace is usually omitted in examples.
|
||||
Format API
|
||||
==========
|
||||
|
||||
The following functions defined in ``fmt/format.h`` use :ref:`format string
|
||||
The following functions defined in ``fmt/core.h`` use :ref:`format string
|
||||
syntax <syntax>` similar to the one used by Python's `str.format
|
||||
<http://docs.python.org/3/library/stdtypes.html#str.format>`_ function.
|
||||
They take *format_str* and *args* as arguments.
|
||||
@ -71,7 +71,7 @@ template and implement ``parse`` and ``format`` methods::
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const MyStruct &s, FormatContext &ctx) {
|
||||
fmt::format_to(ctx.begin(), "[MyStruct: x={:.1f}, y={:.2f}]", s.x, s.y);
|
||||
return format_to(ctx.begin(), "[MyStruct: x={:.1f}, y={:.2f}]", s.x, s.y);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -84,7 +84,7 @@ Then you can pass objects of type ``MyStruct`` to any formatting function::
|
||||
|
||||
In the example above the ``formatter<MyStruct>::parse`` function ignores the
|
||||
contents of the format string referred to by ``ctx.begin()`` so the object will
|
||||
always be formatted as specified. See ``formatter<tm>::parse`` in
|
||||
always be formatted in the same way. See ``formatter<tm>::parse`` in
|
||||
:file:`fmt/time.h` for an advanced example of how to parse the format string and
|
||||
customize the formatted output.
|
||||
|
||||
@ -113,7 +113,7 @@ formatting of user-defined types that have overloaded ``operator<<``::
|
||||
std::string s = fmt::format("The date is {}", Date(2012, 12, 9));
|
||||
// s == "The date is 2012-12-9"
|
||||
|
||||
.. doxygenfunction:: print(std::ostream&, string_view, ArgList)
|
||||
.. doxygenfunction:: print(std::ostream&, string_view, const Args&...)
|
||||
|
||||
Argument formatters
|
||||
-------------------
|
||||
@ -168,13 +168,13 @@ the POSIX extension for positional arguments. Unlike their standard
|
||||
counterparts, the ``fmt`` functions are type-safe and throw an exception if an
|
||||
argument type doesn't match its format specification.
|
||||
|
||||
.. doxygenfunction:: printf(string_view, ArgList)
|
||||
.. doxygenfunction:: printf(string_view, const Args&...)
|
||||
|
||||
.. doxygenfunction:: fprintf(std::FILE *, string_view, ArgList)
|
||||
.. doxygenfunction:: fprintf(std::FILE *, string_view, const Args&...)
|
||||
|
||||
.. doxygenfunction:: fprintf(std::ostream&, string_view, ArgList)
|
||||
.. doxygenfunction:: fprintf(std::ostream&, string_view, const Args&...)
|
||||
|
||||
.. doxygenfunction:: sprintf(string_view, ArgList)
|
||||
.. doxygenfunction:: sprintf(string_view, const Args&...)
|
||||
|
||||
.. doxygenclass:: fmt::PrintfFormatter
|
||||
:members:
|
||||
@ -246,12 +246,12 @@ Utilities
|
||||
System errors
|
||||
=============
|
||||
|
||||
.. doxygenclass:: fmt::SystemError
|
||||
.. doxygenclass:: fmt::system_error
|
||||
:members:
|
||||
|
||||
.. doxygenfunction:: fmt::format_system_error
|
||||
|
||||
.. doxygenclass:: fmt::WindowsError
|
||||
.. doxygenclass:: fmt::windows_error
|
||||
:members:
|
||||
|
||||
.. _formatstrings:
|
||||
|
@ -3233,7 +3233,7 @@ auto join(const Range &range, wstring_view sep)
|
||||
|
||||
**Example**::
|
||||
|
||||
#include "fmt/string.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
std::string answer = fmt::to_string(42);
|
||||
\endrst
|
||||
|
Loading…
Reference in New Issue
Block a user