Standard library enum support via an optional include #2704
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change is a proof of concept implementation that allows C++ enums to be exposed as
enum.Enum
objects on the Python side. I've decided to make this change partly to spark a design discussion about what would make the most sense when trying to expose C++ enums as standard library enums.enum_
? This implementation uses a new object typestdlib_enum
. Personally the backwards compatibility problems seem complex enough that making a new enum type is worthwhile, but there's a tradeoff of increased binary size. I think we would want to phase out the old enum class in favour of this new one.Enum
,IntEnum
,IntFlag
)? If so, how? An optional argument to the constructor seems like the obvious choice.finalize()
method make more sense? How should that interact with being able to add methods (if at all)?TODO: Properly implement
name()
.Currently there are no docs or tests because the design might change a lot.
Kudos to @aldanor who's design I started from.
Implemented #530
Suggested changelog entry: