Update an example

This commit is contained in:
Victor Zverovich 2022-09-21 12:03:18 -07:00
parent a48e3355a6
commit 3272a7a3ce

View File

@ -259,7 +259,7 @@ binary footprint, for example (https://godbolt.org/z/oba4Mc):
.. code:: c++ .. code:: c++
#include <fmt/format.h> #include <fmt/core.h>
void vlog(const char* file, int line, fmt::string_view format, void vlog(const char* file, int line, fmt::string_view format,
fmt::format_args args) { fmt::format_args args) {
@ -267,13 +267,12 @@ binary footprint, for example (https://godbolt.org/z/oba4Mc):
fmt::vprint(format, args); fmt::vprint(format, args);
} }
template <typename S, typename... Args> template <typename... T>
void log(const char* file, int line, const S& format, Args&&... args) { void log(const char* file, int line, fmt::format_string<T...> format, T&&... args) {
vlog(file, line, format, fmt::make_format_args(args...)); vlog(file, line, format, fmt::make_format_args(args...));
} }
#define MY_LOG(format, ...) \ #define MY_LOG(format, ...) log(__FILE__, __LINE__, format, __VA_ARGS__)
log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__)
MY_LOG("invalid squishiness: {}", 42); MY_LOG("invalid squishiness: {}", 42);