Fix custom formatter example (#3820)

Add a return type declaration so the example builds when the formatter is used in a different compilation unit than it's implemented.
This commit is contained in:
frank-weinberg 2024-01-19 17:14:48 +01:00 committed by GitHub
parent 0147e08225
commit 2eb363297b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -139,14 +139,16 @@ without implementing them yourself. For example::
template <> struct fmt::formatter<color>: formatter<string_view> { template <> struct fmt::formatter<color>: formatter<string_view> {
// parse is inherited from formatter<string_view>. // parse is inherited from formatter<string_view>.
auto format(color c, format_context& ctx) const; auto format(color c, format_context& ctx) const
-> format_parse_context::iterator;
}; };
// color.cc: // color.cc:
#include "color.h" #include "color.h"
#include <fmt/format.h> #include <fmt/format.h>
auto fmt::formatter<color>::format(color c, format_context& ctx) const { auto fmt::formatter<color>::format(color c, format_context& ctx) const
-> format_parse_context::iterator {
string_view name = "unknown"; string_view name = "unknown";
switch (c) { switch (c) {
case color::red: name = "red"; break; case color::red: name = "red"; break;