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

Enable comparisons between enums and their underlying types #309

Merged
merged 1 commit into from
Aug 2, 2016

Conversation

pschella
Copy link
Contributor

@pschella pschella commented Aug 2, 2016

For your consideration.

@wjakob
Copy link
Member

wjakob commented Aug 2, 2016

Looks good -- one minor suggestion: can you change __int__ so that it also returns the underlying type?

@pschella
Copy link
Contributor Author

pschella commented Aug 2, 2016

Sounds like a good idea :) Modified __int__ and all other places where int was implicitly used where the underlying type should be used instead.

@wjakob
Copy link
Member

wjakob commented Aug 2, 2016

Great, thank you!

@wjakob wjakob merged commit 6c19f6e into pybind:master Aug 2, 2016
jagerman added a commit to jagerman/pybind11 that referenced this pull request Aug 4, 2016
PR pybind#309 broke scoped enums, which failed to compile because the added:

    value == value2

comparison isn't valid for a scoped enum (they aren't implicitly
convertible to the underlying type).  This commit fixes it by
explicitly converting the enum value to its underlying type before
doing the comparison.
jagerman added a commit to jagerman/pybind11 that referenced this pull request Aug 4, 2016
PR pybind#309 broke scoped enums, which failed to compile because the added:

    value == value2

comparison isn't valid for a scoped enum (they aren't implicitly
convertible to the underlying type).  This commit fixes it by
explicitly converting the enum value to its underlying type before
doing the comparison.

It also adds a scoped enum example to the constants-and-functions
example that triggers the problem fixed in this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants