clang-tidy - cppcoreguidelines-use-enum-class — Extra Clang Tools 21.1.8 documentation

# Extra Clang Tools 21.1.8 documentation

## clang-tidy - cppcoreguidelines-use-enum-class

# cppcoreguidelines-use-enum-class

Finds unscoped (non-class) `enum` declarations and suggests using `enum class` instead.

This check implements Enum.3 from the C++ Core Guidelines.”

Example:

    enum E {};        // use "enum class E {};" instead
    enum class E {};  // OK

    struct S {
        enum E {};    // use "enum class E {};" instead
                      // OK with option IgnoreUnscopedEnumsInClasses
    };

    namespace N {
        enum E {};    // use "enum class E {};" instead
    }

## Options

IgnoreUnscopedEnumsInClasses

  When true, ignores unscoped `enum` declarations in classes. Default is false.