mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Update readme
This commit is contained in:
@ -127,18 +127,18 @@ An object of any user-defined type for which there is an overloaded
|
|||||||
You can create your own functions similar to `format
|
You can create your own functions similar to `format
|
||||||
<http://fmtlib.net/latest/api.html#format>`_ and
|
<http://fmtlib.net/latest/api.html#format>`_ and
|
||||||
`print <http://fmtlib.net/latest/api.html#print>`_
|
`print <http://fmtlib.net/latest/api.html#print>`_
|
||||||
which take arbitrary arguments:
|
which take arbitrary arguments ([godbolt](https://godbolt.org/g/uoSRRh):
|
||||||
|
|
||||||
.. code:: c++
|
.. code:: c++
|
||||||
|
|
||||||
// Prints formatted error message.
|
// Prints formatted error message.
|
||||||
void vreport_error(const char *format, fmt::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_args(args));
|
vreport_error(format, fmt::make_args(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
report_error("file not found: {}", path);
|
report_error("file not found: {}", path);
|
||||||
|
Reference in New Issue
Block a user