Changed to use scoped enum

Changed "reusing existing formatters example" to use scoped enum instead.
This commit is contained in:
Daniel Marshall 2018-09-16 17:09:15 +01:00 committed by Victor Zverovich
parent 59f555ad8f
commit 894b6fac8e

View File

@ -132,7 +132,7 @@ customize the formatted output.
You can also reuse existing formatters, for example:: You can also reuse existing formatters, for example::
enum color {red, green, blue}; enum class color {red, green, blue};
template <> template <>
struct fmt::formatter<color>: formatter<string_view> { struct fmt::formatter<color>: formatter<string_view> {
@ -141,9 +141,9 @@ You can also reuse existing formatters, for example::
auto format(color c, FormatContext &ctx) { auto format(color c, FormatContext &ctx) {
string_view name = "unknown"; string_view name = "unknown";
switch (c) { switch (c) {
case red: name = "red"; break; case color::red: name = "red"; break;
case green: name = "green"; break; case color::green: name = "green"; break;
case blue: name = "blue"; break; case color::blue: name = "blue"; break;
} }
return formatter<string_view>::format(name, ctx); return formatter<string_view>::format(name, ctx);
} }