Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it necessary to add different conversion functions to enum? #11

Closed
Neargye opened this issue Aug 24, 2019 · 2 comments
Closed

Is it necessary to add different conversion functions to enum? #11

Neargye opened this issue Aug 24, 2019 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Neargye
Copy link
Owner

Neargye commented Aug 24, 2019

Now we have

  1. std::optional<E> enum_cast(std::string_view value) noexcept
  2. std::optional<E> enum_cast(std::underlying_type_t<E> value) noexcept

Is it necessary to add the following functions? Will it be useful to someone?

  1. std::optional<E> enum_from_string_nothrow(std::string_view value) noexcept
  2. std::optional<E> enum_from_string_nocase_nothrow(std::string_view value) noexcept
  3. E enum_from_string(std::string_view value)
  4. E enum_from_string_nocase(std::string_view value)
  5. std::optional<E> enum_from_integral_nothrow(std::underlying_type_t<E> value) noexcept
  6. E enum_from_integral(std::underlying_type_t<E> value)
  7. E enum_from_integral_unchecked(std::underlying_type_t<E> value)
    See https://github.com/Neargye/magic_enum/tree/from_functions
@Neargye Neargye added the question Further information is requested label Aug 24, 2019
@alexkaratarakis
Copy link
Contributor

alexkaratarakis commented Aug 29, 2019

Is
std::optional<E> enum_from_string_nothrow(std::string_view value) noexcept
different from:
std::optional<E> enum_cast(std::string_view value) noexcept
?

@Neargye
Copy link
Owner Author

Neargye commented Aug 29, 2019

No.
std::optional<E> enum_cast(std::string_view value) noexcept == std::optional<E> enum_from_string_nothrow(std::string_view value) noexcept
std::optional<E> enum_cast(std::underlying_type_t<E> value) noexcept == std::optional<E> enum_from_integral_nothrow(std::underlying_type_t<E> value) noexcept

@Neargye Neargye added the help wanted Extra attention is needed label Sep 1, 2019
@Neargye Neargye pinned this issue Sep 29, 2019
@Neargye Neargye closed this as completed Oct 2, 2019
@Neargye Neargye unpinned this issue Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants