Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mguludag authored Mar 13, 2024
1 parent 1f524e1 commit 72b7c2f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Converting (scoped)enum values to/from string names written in C++>=11.
* Supports enums in namespaces, classes or structs even templated or not
* Supports compile-time as much as possible using with C++14 and later
* Changing enum range with template parameter <sub>(default range: `[-128, 128)`)</sub> on each call or with your special function for types or adding specialized `enum_range<Enum>` struct
* Supports `operator<<` for direct using with ostream objects
* Supports and automatically overloaded `operator<<` for Enum types to direct using with ostream objects
* Supports custom enum name output by explicit specialization of `constexpr inline auto mgutility::detail::enum_type::name<Enum, EnumValue>() noexcept` function
* Supports iterate over enum (names and values) with `mgutility::enum_for_each<T>()` class and it is compatible with standard ranges and views

Expand All @@ -29,7 +29,7 @@ num class rgb_color { red, green, blue, unknown = -1 };

// specialize rgb_color::unknown to make output "UNKNOWN" instead of "unknown"
template <>
constexpr inline auto mgutility::detail::enum_type::name<rgb_color, rgb_color::unknown>() noexcept
constexpr auto mgutility::detail::enum_type::name<rgb_color, rgb_color::unknown>() noexcept
-> string_view {
return "UNKNOWN";
}
Expand Down Expand Up @@ -78,8 +78,9 @@ auto colors = mgutility::enum_for_each<rgb_color>() |
// default signature: enum_name<min_value = -128, max_value = 128, Enum
// typename>(Enum&&) Changing max_value to not too much greater than enum's
// max value, it will compiles faster
std::cout << mgutility::enum_name(x)
<< '\n'; // will print "blue" to output
std::cout << mgutility::enum_name(x) << '\n'; // will print "blue" to output
// or
std::cout << x << '\n'; // will print "blue" to output

// calling specialized enum ranges function for rgb_color type
// will print "green" to output, if y can't convert to rgb_color prints
Expand Down

0 comments on commit 72b7c2f

Please sign in to comment.