Closed
Description
The following code using a custom formatter example from the documentation fails to compile:
#include <fmt/format.h>
enum class color { red, green, blue };
template <>
struct fmt::formatter<color> : formatter<string_view> {
// parse is inherited from formatter<string_view>.
auto format(color c, format_context& ctx) const -> format_parse_context::iterator;
};
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;
case color::green:
name = "green";
break;
case color::blue:
name = "blue";
break;
}
return formatter<string_view>::format(name, ctx);
}
auto foo(color c) {
return fmt::format("{}", c);
}
Metadata
Metadata
Assignees
Labels
No labels