mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Changed to use scoped enum
Changed "reusing existing formatters example" to use scoped enum instead.
This commit is contained in:
parent
59f555ad8f
commit
894b6fac8e
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user