From 59aa63ac647b9747443a7e9b688ad3dcfc687fcf Mon Sep 17 00:00:00 2001 From: neargye Date: Tue, 8 Sep 2020 20:37:20 +0300 Subject: [PATCH] update doc --- README.md | 4 ++-- doc/reference.md | 12 ++++++------ include/magic_enum.hpp | 32 ++++++++++++++++---------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c85674c..dbf886b 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,12 @@ Header-only C++17 library provides static reflection for enums, work with any en * `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_name` returns name from enum value. * `enum_names` obtains string enum name sequence. * `enum_entries` obtains pair (value enum, string enum name) sequence. * `enum_index` obtains index in enum value sequence from enum value. * `enum_contains` checks whether enum contains enumerator with such value. -* `enum_type_name` returns string name of enum type. +* `enum_type_name` returns name of enum type. * `is_unscoped_enum` checks whether type is an [Unscoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Unscoped_enumeration). * `is_scoped_enum` checks whether type is an [Scoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations). * `underlying_type` improved UB-free "SFINAE-friendly" [std::underlying_type](https://en.cppreference.com/w/cpp/types/underlying_type). diff --git a/doc/reference.md b/doc/reference.md index a4a8566..944014b 100644 --- a/doc/reference.md +++ b/doc/reference.md @@ -5,12 +5,12 @@ * [`enum_values` obtains enum value sequence.](#enum_values) * [`enum_count` returns number of enum values.](#enum_count) * [`enum_integer` obtains integer value from enum value.](#enum_integer) -* [`enum_name` returns string name from enum value.](#enum_name) +* [`enum_name` returns name from enum value.](#enum_name) * [`enum_names` obtains string enum name sequence.](#enum_names) * [`enum_entries` obtains pair (value enum, string enum name) sequence.](#enum_entries) * [`enum_index` obtains index in enum value sequence from enum value.](#enum_index) * [`enum_contains` checks whether enum contains enumerator with such value.](#enum_contains) -* [`enum_type_name` returns string name of enum type.](#enum_type_name) +* [`enum_type_name` returns type name of enum.](#enum_type_name) * [`is_unscoped_enum` checks whether type is an Unscoped enumeration.](#is_unscoped_enum) * [`is_scoped_enum` checks whether type is an Scoped enumeration.](#is_scoped_enum) * [`underlying_type` improved UB-free "SFINAE-friendly" std::underlying_type.](#underlying_type) @@ -146,7 +146,7 @@ template constexpr string_view enum_name() noexcept; ``` -* Returns `std::string_view` with null-terminated string name from enum value. +* Returns name from enum value as `std::string_view` with null-terminated string. * If enum value does not have name or [out of range](limitations.md), `enum_name(value)` returns empty string. * If enum value does not have name, `enum_name()` occurs the compilation error `"Enum value does not have a name."`. @@ -177,7 +177,7 @@ template constexpr array enum_names() noexcept; ``` -* Returns `std::array` with all string names where `N = number of enum values`, sorted by enum value. +* Returns `std::array` with all names where `N = number of enum values`, sorted by enum value. * Examples @@ -194,7 +194,7 @@ template constexpr array, N> enum_entries() noexcept; ``` -* Returns `std::array, N>` with all pairs (enum value, string name) where `N = number of enum values`, sorted by enum value. +* Returns `std::array, N>` with all pairs (value, name) where `N = number of enum values`, sorted by enum value. * Examples @@ -261,7 +261,7 @@ template constexpr string_view enum_type_name() noexcept; ``` -* Returns `std::string_view` with null-terminated string name of enum type. +* Returns type name of enum as `std::string_view` null-terminated string. * Examples diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index fa8e5a1..4f22747 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -626,7 +626,7 @@ struct underlying_type : detail::underlying_type {}; template using underlying_type_t = typename underlying_type::type; -// Returns string name of enum type. +// Returns type name of enum. template [[nodiscard]] constexpr auto enum_type_name() noexcept -> std::enable_if_t>, string_view> { using D = std::decay_t; @@ -665,7 +665,7 @@ template return detail::values_v; } -// Returns string name from static storage enum variable. +// Returns name from static storage enum variable. // This version is much lighter on the compile times and is not restricted to the enum_range limitation. template [[nodiscard]] constexpr auto enum_name() noexcept -> std::enable_if_t>, string_view> { @@ -676,7 +676,7 @@ template return name; } -// Returns string name from enum value. +// Returns name from enum value. // If enum value does not have name or value out of range, returns empty string. template [[nodiscard]] constexpr auto enum_name(E value) noexcept -> detail::enable_if_enum_t { @@ -689,7 +689,7 @@ template return {}; // Invalid value or out of range. } -// Returns std::array with string names, sorted by enum value. +// Returns std::array with names, sorted by enum value. template [[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_enum_t> { using D = std::decay_t; @@ -697,7 +697,7 @@ template return detail::names_v; } -// Returns std::array with pairs (enum value, string name), sorted by enum value. +// Returns std::array with pairs (value, name), sorted by enum value. template [[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_enum_t> { using D = std::decay_t; @@ -718,7 +718,7 @@ template return {}; // Invalid value or out of range. } -// Obtains enum value from string name. +// Obtains enum value from name. // Returns optional with enum value. template [[nodiscard]] constexpr auto enum_cast(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v) -> detail::enable_if_enum_t>> { @@ -734,7 +734,7 @@ template return {}; // Invalid value or out of range. } -// Obtains enum value from string name. +// Obtains enum value from name. // Returns optional with enum value. template [[nodiscard]] constexpr auto enum_cast(string_view value) noexcept -> detail::enable_if_enum_t>> { @@ -778,7 +778,7 @@ template return detail::undex(value) != detail::invalid_index_v; } -// Checks whether enum contains enumerator with such string name. +// Checks whether enum contains enumerator with such name. template [[nodiscard]] constexpr auto enum_contains(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v) -> detail::enable_if_enum_t { using D = std::decay_t; @@ -787,7 +787,7 @@ template return enum_cast(value, std::move_if_noexcept(p)).has_value(); } -// Checks whether enum contains enumerator with such string name. +// Checks whether enum contains enumerator with such name. template [[nodiscard]] constexpr auto enum_contains(string_view value) noexcept -> detail::enable_if_enum_t { using D = std::decay_t; @@ -860,7 +860,7 @@ constexpr E& operator^=(E& lhs, E rhs) noexcept { namespace flags { -// Returns string name of enum type. +// Returns type name of enum. using magic_enum::enum_type_name; // Returns number of enum-flags values. @@ -894,7 +894,7 @@ template return detail::values_v; } -// Returns string name from enum-flags value. +// Returns name from enum-flags value. // If enum-flags value does not have name or value out of range, returns empty string. template [[nodiscard]] auto enum_name(E value) -> detail::enable_if_enum_flags_t { @@ -929,7 +929,7 @@ template return detail::names_v; } -// Returns std::array with pairs (enum-flags value, string name), sorted by enum-flags value. +// Returns std::array with pairs (value, name), sorted by enum-flags value. template [[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_enum_flags_t> { using D = std::decay_t; @@ -967,7 +967,7 @@ template return {}; // Invalid value or out of range. } -// Obtains enum-flags value from string name. +// Obtains enum-flags value from name. // Returns optional with enum-flags value. template [[nodiscard]] constexpr auto enum_cast(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v) -> detail::enable_if_enum_flags_t>> { @@ -1000,7 +1000,7 @@ template } } -// Obtains enum-flags value from string name. +// Obtains enum-flags value from name. // Returns optional with enum-flags value. template [[nodiscard]] constexpr auto enum_cast(string_view value) noexcept -> detail::enable_if_enum_flags_t>> { @@ -1047,7 +1047,7 @@ template return enum_cast(value).has_value(); } -// Checks whether enum-flags contains enumerator with such string name. +// Checks whether enum-flags contains enumerator with such name. template [[nodiscard]] constexpr auto enum_contains(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v) -> detail::enable_if_enum_flags_t { static_assert(std::is_invocable_r_v, "magic_enum::flags::enum_contains requires bool(char, char) invocable predicate."); @@ -1056,7 +1056,7 @@ template return enum_cast(value, std::move_if_noexcept(p)).has_value(); } -// Checks whether enum-flags contains enumerator with such string name. +// Checks whether enum-flags contains enumerator with such name. template [[nodiscard]] constexpr auto enum_contains(string_view value) noexcept -> detail::enable_if_enum_flags_t { using D = std::decay_t;