very declaration of an enum type must be a complete definition containing a full list of its enumerators. However, in some use cases declaring an enumeration without providing the enumerators list is desirable. For example, you may use a forward declaration like this...

enum class Direction;

...instead of repeating the complete definition (see below) in every translation unit.

enum class Direction: short {Up, Down};

A year ago, the C++ standards committee voted into the Working Draft a proposal to add forward declarations of enum types. This 10-Minute Solution shows how to use forward declarations of enum types to expedite compilation time and reduce code dependencies.



Your project has an enum type containing hundreds of machine-generated enumerators that change frequently. You must provide a complete definition of that enum in every translation unit, even if the compiler seemingly doesn't need the complete definition of the enum.



Replace complete definitions of enum types with forward enum declarations where possible.