Doc Comments /
Enum
Difference (last change) (no other diffs, normal page display)
Deleted: 103,213d102
Enums
![]() |
|
Examples
Explicit Initialization
Quick basic example of explicit initialization of enums perhaps assumed to be 'obvious' by the documentation:
![]() |
|
Note the example above requires full qualification. If you find this cumbersome, you can ease the pain with an alias.
![]() |
|
- JoseSantos -
Comments
Add your comments here.
Virtual Enumeration
something I find missing from c++ is "virtual enumeration". there are cases when a subclass needs to redefine the items of an enum field. this can be solved by using integers, but debugging now becomes more difficult since the values are no longer presented by their enumeration members, even though the debugger knows the type of class it is dealing with. the c++ usage would have been something like this:
![]() |
|
technically, this means the type of x had changed, but maybe in D it would be legal.
Extendable Enums
I would like to have extendable enums:
![]() |
|
init property for enums
The first enum value (.init) often happens to be the minimum, but this is not true when they are assigned out of order. Looking below, .min = 0 but .init = 6 (perhaps there should be an alternate way to specify the initial value as to avoid reordering the values and risking overlap?).
![]() |
|
Links