Skip to content

Commit

Permalink
Changed to use scoped enum
Browse files Browse the repository at this point in the history
Changed "reusing existing formatters example" to use scoped enum instead.
SuperWig authored and vitaut committed Sep 17, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 59f555a commit 894b6fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/api.rst
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ customize the formatted output.

You can also reuse existing formatters, for example::

enum color {red, green, blue};
enum class color {red, green, blue};

template <>
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) {
string_view name = "unknown";
switch (c) {
case red: name = "red"; break;
case green: name = "green"; break;
case blue: name = "blue"; break;
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);
}

0 comments on commit 894b6fa

Please sign in to comment.