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:
parent
0147e08225
commit
2eb363297b
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user