Skip to content

Commit

Permalink
Fix custom formatter example (#3820)
Browse files Browse the repository at this point in the history
Add a return type declaration so the example builds when the formatter is used in a different compilation unit than it's implemented.
  • Loading branch information
frank-weinberg authored Jan 19, 2024
1 parent 0147e08 commit 2eb3632
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2eb3632

Please sign in to comment.