mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-25 03:30:05 +00:00
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> {
|
||||
// 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:
|
||||
#include "color.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";
|
||||
switch (c) {
|
||||
case color::red: name = "red"; break;
|
||||
|
Loading…
Reference in New Issue
Block a user