Title: Pxxxx: Add inheritance for Enum Class enumerations
Author: Andrey Fokin, lazzyfox@gmaoil.coml
Date: 2026-04-20
Project: Programming Language C++, Library Working Group
Abstract: New inheritance feature to enum class (scoped enumerations)
1. Introduction
According my experience the are situations when scped enumerations could be presented in OOP style – base enumeration type and some ancestors of. For example – we have to define a list of colors for traffic lights device. Is simple case we have just three colors and our enum could looks like
enum class TrafficLight:uint8_t { Red, Yellow, Green };
And probably this enum will cover biggest part of cases. But if we need to have a case wit Trafficligt wit left, rgih or two arrows we need ot use three diffeerent data types for each with big part of duplicated data in eatch.
Case 1- additional letf arrow enum class TrafficLight_LefatArrow:uint8_t { Red, Yellow, Green, LeftArrow };
Case 2- additional right arrow enum class TrafficLight_RightArrow:uint8_t { Red, Yellow, Green, RightArrow };
Case 3- two additional arrows enum class TrafficLight_TwoArrows:uint8_t { Red, Yellow, Green, LeftArrow, RightArrow };
In case of inheritance could be possible use as first case as a base class and athers as inherited to exclude overlapping data duplication and casese above cold looks like
Case 4- additional letf arrow enum class TrafficLight:LefatArrow:uint8_t {LeftArrow };
Case 5- additional right arrow enum class TrafficLight:RightArrow:uint8_t {RightArrow };
Case 6- two additional arrows enum class TrafficLight_TwoArrows:uint8_t {LeftArrow, RightArrow };
2. Motivation and scope
Proposal could make more cleare code structure and decrease code overlapping and had writing
3. Design decisions
It could be compiler extension
BRG,
Andrey
--