make example compatible with fmt 11 (#3130)

Since fmt 11.0.0, formatter::format() is required to be const. Mark
format() method in example as const to stay compatible with fmt 11.
This commit is contained in:
Ziyao 2024-07-09 04:14:30 +08:00 committed by GitHub
parent eeb22c13bb
commit d276069a6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -272,7 +272,7 @@ struct my_type {
#ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib
template <>
struct fmt::formatter<my_type> : fmt::formatter<std::string> {
auto format(my_type my, format_context &ctx) -> decltype(ctx.out()) {
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
}
};