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

clen-up & improve (#173)

This commit is contained in:
Daniil Goncharov 2022-03-28 19:15:38 +04:00 committed by GitHub
parent 2e7313d3f7
commit 2615fa5e7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -371,11 +371,32 @@ template <typename... Es>
## `enum_switch` ## `enum_switch`
TODO ```cpp
template <typename Result = void, typename E, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, E value);
template <typename Result, typename E, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, E value, Result&& result);
template <typename E, typename Result = void, typename BinaryPredicate = std::equal_to<>, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, string_view name, BinaryPredicate&& p = {});
template <typename E, typename Result, typename BinaryPredicate = std::equal_to<>, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, string_view name, Result&& result, BinaryPredicate&& p = {});
template <typename E, typename Result = void, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, underlying_type_t<E> value);
template <typename E, typename Result, typename Lambda>
constexpr Result enum_switch(Lambda&& lambda, underlying_type_t<E> value, Result&& result);
```
## `enum_for_each` ## `enum_for_each`
TODO ```cpp
template <typename E, typename Lambda>
constexpr auto enum_for_each(Lambda&& lambda);
```
## `is_unscoped_enum` ## `is_unscoped_enum`

View file

@ -990,7 +990,7 @@ template <typename E>
// Returns underlying value from enum value. // Returns underlying value from enum value.
template <typename E> template <typename E>
[[nodiscard]] constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_enum_t<E, underlying_type_t<E>> { [[nodiscard]] constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_t<E, underlying_type_t<E>> {
return static_cast<underlying_type_t<E>>(value); return static_cast<underlying_type_t<E>>(value);
} }