Since {cpp}11, it's possible to declare the underlying type of an ``++enum++``, and like any type declration, ``++enum++`` declarations can contain the ``++const++`` or ``++volatile++`` specifier. But because ``++enum++`` values are named constants and cannot be re-assigned, those specifiers are ignored by the compiler, and are therefore useless.


This rule raises an issue if ``++const++`` or ``++volatile++`` is present in the declaration of the underlying type of an ``++enum++``.


== Noncompliant Code Example

----
enum class Color : const long int {  // Noncompliant; Remove this "const" specifier.
  Red   = 0xff0000,
  Green = 0x00ff00,
  Blue  = 0x0000ff
};

enum class Size : volatile char {  // Noncompliant; Remove this "volatile" specifier.
  Small   = 's',
  Big     = 'b'
};
----


== Compliant Solution

----
enum class Color : long int {
  Red   = 0xff0000,
  Green = 0x00ff00,
  Blue  = 0x0000ff
};

enum class Size : char {
  Small   = 's',
  Big     = 'b'
};
----



ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
