On Sun, 02 Jun 2013 20:03 -0700, Jonathan M Davis <jmdavisp...@gmx.com> wrote: > Your suggestion for an "invalid" value for the first enum value > was a good one and should be enough IMHO if you don't want the default enum > value > to be valid.
Actually, I just figured out that we already have support for what I've asked for: enum_mod.d: ----- module enum_mod; private enum MachineEnum { X86, X86_64, } struct InitEnum(E) if (is(E == enum)) { @disable this(); this(E e) { value = e; } E value; alias value this; } alias Machine = InitEnum!MachineEnum; // "fake" enum ----- test.d: ----- import enum_mod; void main() { // Machine machine; // compile-time error Machine machine = Machine.X86; // ok } ----- How damn cool is that?