forked from fmtlib/fmt
Improve example.
This commit is contained in:
11
README.rst
11
README.rst
@ -99,13 +99,14 @@ which take arbitrary arguments:
|
|||||||
|
|
||||||
.. code-block:: c++
|
.. code-block:: c++
|
||||||
|
|
||||||
// Prints formatted error message to std::cerr.
|
// Prints formatted error message.
|
||||||
void ReportError(const char *format_str, const fmt::ArgList &args) {
|
void report_error(const char *format, const fmt::ArgList &args) {
|
||||||
std::cerr << "Error: " << fmt::format(format_str, args) << std::endl;
|
fmt::print("Error: {}");
|
||||||
|
fmt::print(format, args);
|
||||||
}
|
}
|
||||||
FMT_VARIADIC(void, ReportError, const char *)
|
FMT_VARIADIC(void, report_error, const char *)
|
||||||
|
|
||||||
ReportError("File not found: {}", path);
|
report_error("file not found: {}", path);
|
||||||
|
|
||||||
Note that you only need to define one function that takes ``const fmt::ArgList &``
|
Note that you only need to define one function that takes ``const fmt::ArgList &``
|
||||||
argument and ``FMT_VARIADIC`` automatically defines necessary wrappers that
|
argument and ``FMT_VARIADIC`` automatically defines necessary wrappers that
|
||||||
|
Reference in New Issue
Block a user