I've been wondering if we could have parameterized named enumS. The syntax for it would look somewhat similar:

enum Fruit(T) : T { apple, banana = -42 }

void main()
{
    auto shortFruit = Fruit!(short).apple;
    auto longFruit  = Fruit!(long).banana;

    longFruit = shortFruit; // OK: implicit conversion allowed
    shortFruit = longFruit; // OK: ... even a truncating one

    Fruit!uint uintFruit; // Error: -42 is out of range of uint
    Fruit!string stringFruit; // Error: enums need initializers
}

Reply via email to