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

Enhancement: Optional comparison predicate for enum_cast(std::string_view value) [case-insensitive, etc] #35

Closed
jbhelm opened this issue Mar 22, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jbhelm
Copy link

jbhelm commented Mar 22, 2020

It would be useful to optionally pass a comparison predicate to use for the equality comparison in enum_cast(std::string_view value). In my case, I'd like to perform case-insensitive comparisons.

@Neargye Neargye self-assigned this Mar 22, 2020
@Neargye Neargye added the enhancement New feature or request label Mar 22, 2020
@Neargye
Copy link
Owner

Neargye commented Mar 22, 2020

Yes, good idea

@Neargye
Copy link
Owner

Neargye commented Apr 2, 2020

@jbhelm update in master.
Now it's work

enum_cast<Color>("blue", [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }).value() == Color::BLUE

@Neargye Neargye closed this as completed Apr 2, 2020
@jbhelm
Copy link
Author

jbhelm commented Apr 2, 2020

Thanks! I tried it out, works great for my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants