Commit 894b6fac authored by Daniel Marshall's avatar Daniel Marshall Committed by Victor Zverovich

Changed to use scoped enum

Changed "reusing existing formatters example" to use scoped enum instead.
parent 59f555ad
...@@ -132,7 +132,7 @@ customize the formatted output. ...@@ -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:: ...@@ -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);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment