Implicit enum conversions are a stupid PITA

bearophile bearophileHUGS at lycos.com
Wed Mar 24 09:35:24 PDT 2010


Another possible syntax that I don't like:

private enum ubyte enum_Todo {
    do_nothing,
    walk_dog,
    cook_breakfast,
    deliver_newspaper,
    visit_miss_kerbopple,
    wash_covers
}

alias Flags!(enum_Todo) Todo;

(Essentially the @flags attribute can do this, and avoid to define the enum).


This doesn't work, you can't pass locally defined anonymous enums to templates:

alias Flags!(enum ubyte { do_nothing,
                          walk_dog,
                          cook_breakfast,
                          deliver_newspaper,
                          visit_miss_kerbopple,
                          wash_covers
                        }) Todo;

Bye,
bearophile



More information about the Digitalmars-d mailing list