[Development] Proposing to change https://wiki.qt.io/API_Design_Principles#Enums_in_classes to require scoped enums

Sune Vuorela nospam at vuorela.dk
Mon Jan 20 11:33:00 CET 2025


On 2025-01-16, Marc Mutz via Development <development at qt-project.org> wrote:
> Can we, please, settle this by strengthening the wording of 
> https://wiki.qt.io/API_Design_Principles#Enums_in_classes to something 
> that requires scoped enums?
>
> I believe everyone agrees that there are _technical_ reasons to prefer 
> scoped enums: no implicit conversion to underlying_type, defined 
> underlying type even if not explicitly given, etc.

> But the implicit conversions of unscoped enums are still unwanted!

I do actually think there is a place where we want unscoped enums.

And that's when they are more used as a constant and as an extension
point.

Places like this are 
 - the roles in the item models.
 - event types

(and maybe others of the same pattern)

Making these scoped enums; I just don't see where the gain is, but I see
lots of pain.

For most othes, though current naming is a bit weird, I prefer scoped
enums.

/Sune



More information about the Development mailing list