1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00

update doc

This commit is contained in:
neargye 2020-09-08 20:37:20 +03:00
parent 690486e7f2
commit 59aa63ac64
3 changed files with 24 additions and 24 deletions

View file

@ -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).

View file

@ -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 <auto V>
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<value>()` occurs the compilation error `"Enum value does not have a name."`.
@ -177,7 +177,7 @@ template <typename E>
constexpr array<string_view, N> enum_names() noexcept;
```
* Returns `std::array<std::string_view, N>` with all string names where `N = number of enum values`, sorted by enum value.
* Returns `std::array<std::string_view, N>` with all names where `N = number of enum values`, sorted by enum value.
* Examples
@ -194,7 +194,7 @@ template <typename E>
constexpr array<pair<E, string_view>, N> enum_entries() noexcept;
```
* Returns `std::array<std::pair<E, std::string_view>, N>` with all pairs (enum value, string name) where `N = number of enum values`, sorted by enum value.
* Returns `std::array<std::pair<E, std::string_view>, N>` with all pairs (value, name) where `N = number of enum values`, sorted by enum value.
* Examples
@ -261,7 +261,7 @@ template <typename E>
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

View file

@ -626,7 +626,7 @@ struct underlying_type : detail::underlying_type<T> {};
template <typename T>
using underlying_type_t = typename underlying_type<T>::type;
// Returns string name of enum type.
// Returns type name of enum.
template <typename E>
[[nodiscard]] constexpr auto enum_type_name() noexcept -> std::enable_if_t<std::is_enum_v<std::decay_t<E>>, string_view> {
using D = std::decay_t<E>;
@ -665,7 +665,7 @@ template <typename E>
return detail::values_v<D>;
}
// 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 <auto V>
[[nodiscard]] constexpr auto enum_name() noexcept -> std::enable_if_t<std::is_enum_v<std::decay_t<decltype(V)>>, string_view> {
@ -676,7 +676,7 @@ template <auto V>
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 <typename E>
[[nodiscard]] constexpr auto enum_name(E value) noexcept -> detail::enable_if_enum_t<E, string_view> {
@ -689,7 +689,7 @@ template <typename E>
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 <typename E>
[[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_enum_t<E, detail::names_t<E>> {
using D = std::decay_t<E>;
@ -697,7 +697,7 @@ template <typename E>
return detail::names_v<D>;
}
// 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 <typename E>
[[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_enum_t<E, detail::entries_t<E>> {
using D = std::decay_t<E>;
@ -718,7 +718,7 @@ template <typename E>
return {}; // Invalid value or out of range.
}
// Obtains enum value from string name.
// Obtains enum value from name.
// Returns optional with enum value.
template <typename E, typename BinaryPredicate>
[[nodiscard]] constexpr auto enum_cast(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v<bool, BinaryPredicate, char, char>) -> detail::enable_if_enum_t<E, optional<std::decay_t<E>>> {
@ -734,7 +734,7 @@ template <typename E, typename BinaryPredicate>
return {}; // Invalid value or out of range.
}
// Obtains enum value from string name.
// Obtains enum value from name.
// Returns optional with enum value.
template <typename E>
[[nodiscard]] constexpr auto enum_cast(string_view value) noexcept -> detail::enable_if_enum_t<E, optional<std::decay_t<E>>> {
@ -778,7 +778,7 @@ template <typename E>
return detail::undex<D>(value) != detail::invalid_index_v<D>;
}
// Checks whether enum contains enumerator with such string name.
// Checks whether enum contains enumerator with such name.
template <typename E, typename BinaryPredicate>
[[nodiscard]] constexpr auto enum_contains(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v<bool, BinaryPredicate, char, char>) -> detail::enable_if_enum_t<E, bool> {
using D = std::decay_t<E>;
@ -787,7 +787,7 @@ template <typename E, typename BinaryPredicate>
return enum_cast<D>(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 <typename E>
[[nodiscard]] constexpr auto enum_contains(string_view value) noexcept -> detail::enable_if_enum_t<E, bool> {
using D = std::decay_t<E>;
@ -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 <typename E>
return detail::values_v<D, true>;
}
// 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 <typename E>
[[nodiscard]] auto enum_name(E value) -> detail::enable_if_enum_flags_t<E, string> {
@ -929,7 +929,7 @@ template <typename E>
return detail::names_v<D, true>;
}
// 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 <typename E>
[[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_enum_flags_t<E, detail::entries_t<E, true>> {
using D = std::decay_t<E>;
@ -967,7 +967,7 @@ template <typename E>
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 <typename E, typename BinaryPredicate>
[[nodiscard]] constexpr auto enum_cast(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v<bool, BinaryPredicate, char, char>) -> detail::enable_if_enum_flags_t<E, optional<std::decay_t<E>>> {
@ -1000,7 +1000,7 @@ template <typename E, typename BinaryPredicate>
}
}
// Obtains enum-flags value from string name.
// Obtains enum-flags value from name.
// Returns optional with enum-flags value.
template <typename E>
[[nodiscard]] constexpr auto enum_cast(string_view value) noexcept -> detail::enable_if_enum_flags_t<E, optional<std::decay_t<E>>> {
@ -1047,7 +1047,7 @@ template <typename E>
return enum_cast<D>(value).has_value();
}
// Checks whether enum-flags contains enumerator with such string name.
// Checks whether enum-flags contains enumerator with such name.
template <typename E, typename BinaryPredicate>
[[nodiscard]] constexpr auto enum_contains(string_view value, BinaryPredicate p) noexcept(std::is_nothrow_invocable_r_v<bool, BinaryPredicate, char, char>) -> detail::enable_if_enum_flags_t<E, bool> {
static_assert(std::is_invocable_r_v<bool, BinaryPredicate, char, char>, "magic_enum::flags::enum_contains requires bool(char, char) invocable predicate.");
@ -1056,7 +1056,7 @@ template <typename E, typename BinaryPredicate>
return enum_cast<D>(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 <typename E>
[[nodiscard]] constexpr auto enum_contains(string_view value) noexcept -> detail::enable_if_enum_flags_t<E, bool> {
using D = std::decay_t<E>;