Preliminary documentation for Ice for MATLAB. Do not use in production applications. Refer to the space directory for other releases.

A Slice enumeration maps to the corresponding enum class in C++.

For example:

Slice
enum Fruit { Apple, Pear, Orange }

The generated C++ enumeration is:

C++
enum class Fruit : unsigned char { Apple, Pear, Orange };

The underlying type is unsigned char when the enumeration's largest enumerator value is not greater than 254, otherwise it's the default, int.

You can alternatively generate an old-style unscoped enum with the cpp:unscoped metadata directive.

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 class Fruit : unsigned char { Apple = 0, Pear = 3, Orange = 4 };

See Also

  • No labels