C++ Mapping for Enumerations

A Slice enumeration maps to the corresponding enumeration in C++. For example:

Slice
enum Fruit { Apple, Pear, Orange };

Not surprisingly, the generated C++ definition is identical:

C++
enum Fruit { Apple, Pear, Orange };

Suppose we modify the Slice definition to include a custom enumerator value:

Slice
enum Fruit { Apple, Pear = 3, Orange };

The generated C++ definition now includes an explicit initializer for every enumerator:

C++
enum Fruit { Apple = 0, Pear = 3, Orange = 4 };

See Also