Is there a C++ guideline to make first enum a "safe" default?

Viewed 115

I make the first enum a "safe" default value in my C++ code, but I cannot find an "official" guideline to quote to back up this practice.

Consider the struct:

struct MyNuke {
    enum {
        Detonate,
        Disable
    } state;
};

I'm using a C++03 compiler. I cannot add a constructor because the struct is used in a union. I cannot get rid of the union because that is not my code.

Calling the default constructor zero-initializes the struct members:

MyNuke nuke = MyNuke();

The value of nuke.state is now Detonate. Disable would be a safer first value.

It seems logical to make the first enum a "safe" value. Are there any C++ guidelines on this?

2 Answers
Related