Interface defining the basic functionality of an enum class.
Template mixin to add enum functionality to a class.
Template which evaluates to a string containing the code for a list of enum members, as specified by the first two members of the passed tuple, which must be an array of strings and an array of integers, respectively. The strings specify the names of the enum members, and the integers their values.
Template which evaluates to a size_t corresponding to the index in the type tuple T which contains a class implementing the IEnum interface. If no such type exists in T, then the template evaluates to T.length.
Mixin for an enum class with the following basic features: * Contains an enum, called E, with members specified by an associative array passed to the mixin. * Implements an interface, IEnum, with common shared methods: * opIndex: look up an enum member's name by its value and vice-versa. * opIn_r: check whether a value (int) or name (char[]) is a member of the enum. * opApply: iteration over over the names & values of the enum's members. * length: returns the number of members in the enum. * min & max: return the minimum/maximum value of the enum's members. * A static opCall() method which returns a singleton instance of the class. This is the most convenient means of calling the methods listed above.
Basic usage example:
The mixin also supports the following more advanced features: * One enum class can be inherited from another, using standard class inheritance. The enum members in a derived enum class extend those of the super class. * The use of normal class inheritance, along with the IEnum interface, allows enum classes to be used abstractly.
Advanced usage example:
TODO: does it matter that the enum values are always int? We could add a template parameter to specify the base type, but I think it'd be a shame to make things more complex. IEnum would have to become a template then.