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

update doc

This commit is contained in:
neargye 2019-10-03 19:43:18 +05:00
parent cd73e2b974
commit 2a259f1b55

View file

@ -57,7 +57,7 @@ constexpr optional<E> enum_cast(underlying_type_t<E> value) noexcept;
## `enum_value` ## `enum_value`
```cpp ```cpp
template <typename E> template <typename E>
constexpr E enum_value(std::size_t index) noexcept; constexpr E enum_value(size_t index) noexcept;
``` ```
* Returns enum value at specified index. * Returns enum value at specified index.
@ -118,10 +118,10 @@ constexpr underlying_type_t<E> enum_integer(E value) noexcept;
## `enum_name` ## `enum_name`
```cpp ```cpp
template <typename E> template <typename E>
constexpr std::string_view enum_name(E value) noexcept; constexpr string_view enum_name(E value) noexcept;
template <auto V> template <auto V>
constexpr std::string_view enum_name() noexcept; constexpr string_view enum_name() noexcept;
``` ```
* Returns `std::string_view`. If enum value does not have name, returns empty string. * Returns `std::string_view`. If enum value does not have name, returns empty string.
@ -147,7 +147,7 @@ constexpr std::string_view enum_name() noexcept;
## `enum_names` ## `enum_names`
```cpp ```cpp
template <typename E> template <typename E>
constexpr array<std::string_view, N> enum_names() noexcept; constexpr array<string_view, N> enum_names() noexcept;
``` ```
* Returns `std::array<std::string_view, N>` with all string enum name where `N = number of enum values`, sorted by enum value. * Returns `std::array<std::string_view, N>` with all string enum name where `N = number of enum values`, sorted by enum value.
@ -162,7 +162,7 @@ constexpr array<std::string_view, N> enum_names() noexcept;
## `enum_entries` ## `enum_entries`
```cpp ```cpp
template <typename E> template <typename E>
constexpr array<std::pair<E, std::string_view>, N> enum_entries() noexcept; constexpr array<pair<E, string_view>, N> enum_entries() noexcept;
``` ```
* Returns `std::array<std::pair<E, std::string_view>, N>` with all `std::pair` (value enum, string enum name) where `N = number of enum values`, sorted by enum value. * Returns `std::array<std::pair<E, std::string_view>, N>` with all `std::pair` (value enum, string enum name) where `N = number of enum values`, sorted by enum value.
@ -244,10 +244,10 @@ using underlying_type_t = typename underlying_type<T>::type;
## `ostream_operators` ## `ostream_operators`
```cpp ```cpp
template <typename Char, typename Traits, typename E> template <typename Char, typename Traits, typename E>
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, E value); basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os, E value);
template <typename Char, typename Traits, typename E> template <typename Char, typename Traits, typename E>
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, std::optional<E> value); basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os, optional<E> value);
``` ```
* Out-of-the-box ostream operators for enums. * Out-of-the-box ostream operators for enums.