diff --git a/README.md b/README.md index 7c7b33c..84c2b31 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code. * `enum_cast` obtains enum value from string or integer. -* `enum_integer_value` obtains integer value from enum value. * `enum_value` returns enum value at specified index. * `enum_values` obtains enum value sequence. * `enum_count` returns number of enum values. +* `enum_integer` obtains integer value from enum value. * `enum_name` returns string name from enum value. * `enum_names` obtains string enum name sequence. * `enum_entries` obtains pair (value enum, string enum name) sequence. @@ -110,13 +110,6 @@ enum Color { RED = 2, BLUE = 4, GREEN = 8 }; // color -> Color::RED ``` -* Enum value to integer - ```cpp - Color color = Color::RED; - auto color_integer = magic_enum::enum_integer_value(color); - // color -> 2 - ``` - * Enum value sequence ```cpp constexpr auto colors = magic_enum::enum_values(); @@ -130,6 +123,13 @@ enum Color { RED = 2, BLUE = 4, GREEN = 8 }; // color_count -> 3 ``` +* Enum value to integer + ```cpp + Color color = Color::RED; + auto color_integer = magic_enum::enum_integer(color); + // color -> 2 + ``` + * Enum names sequence ```cpp constexpr auto color_names = magic_enum::enum_names(); diff --git a/example/example.cpp b/example/example.cpp index 4a888bf..c88cc46 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -54,9 +54,9 @@ int main() { } // Enum value to integer value. - auto color_integer_value = magic_enum::enum_integer_value(Color::RED); - if (color_integer_value == static_cast>(Color::RED)) { - std::cout << "RED = " << color_integer_value << std::endl; // RED = -10 + auto color_integer = magic_enum::enum_integer(Color::RED); + if (color_integer == static_cast>(Color::RED)) { + std::cout << "RED = " << color_integer << std::endl; // RED = -10 } using namespace magic_enum::ops; // out-of-the-box stream operator for enums. diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 42ed589..12ae221 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -245,9 +245,9 @@ template > // Returns integer value from enum value. template > -[[nodiscard]] constexpr auto enum_integer_value(E value) noexcept { +[[nodiscard]] constexpr auto enum_integer(E value) noexcept { using D = std::decay_t; - static_assert(std::is_enum_v, "magic_enum::enum_integer_value requires enum type."); + static_assert(std::is_enum_v, "magic_enum::enum_integer requires enum type."); return static_cast>(value); }