Support for C++ scoped enum class
See original GitHub issueThere is currently no sane way to represent enum class
in .pxd
.
namespace lol {
enum class rofl : int {
SOMETHING,
MOAR = 1337
};
// at this point, accessible as rofl::MOAR
}
// here, accessible as lol::rofl::MOAR
A possible way of representing it would be:
cdef extern from "headername.h" namespace "lol":
cdef enumclass rofl:
SOMETHING
MOAR
# accessed as
rofl.MOAR
Related: #1567
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Scoped (class) enums: fundamentals and examples - nextptr
Scoped enums (enum class/struct) are strongly typed enumerations introduced in C++11. They address several shortcomings of the old C-style (C++ ...
Read more >Scope of enum in C vs C++ - Stack Overflow
In C, there is simply no rule for scope for enums and struct. The place where you define your enum doesn't have any...
Read more >Get to Know C++11 Scoped and Based Enum Types
C ++11 offers two new categories of enum types: scoped enums and based enums. Enumerators of a scoped enum require a qualified name...
Read more >Enumeration declaration - cppreference.com
An enumeration is a distinct type whose value is restricted to a range of values (see below for details), which may include several ......
Read more >10.4 — Scoped enumerations (enum classes) - Learn C++
Introduced in C++20, a using enum statement imports all of the enumerators from an enum into the current scope. When used with an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this workaround is also good:
And then:
I had this same problem and came to the same workaround solution back in 2013: https://stackoverflow.com/a/15566540/496445
Someone brought this up to me today and I had a poke around to see if anything has improved around this since that time, but then I came across this ticket with the same workarounds.