4.22 Attribute Enum_Val

Note that this attribute is now standard in Ada 202x and is available as an implementation defined attribute for earlier Ada versions.

For every enumeration subtype S, S'Enum_Val denotes a function with the following spec:

function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;

The function returns the enumeration value whose representation matches the argument, or raises Constraint_Error if no enumeration literal of the type has the matching value. This will be equal to value of the Val attribute in the absence of an enumeration representation clause. This is a static attribute (i.e., the result is static if the argument is static).