[Development] API style guide: scoped enum or not?

Volker Hilsheimer volker.hilsheimer at qt.io
Tue May 2 10:58:44 CEST 2023


During the header review, but also in API discussions leading up to it, we had a few cases where it would have helped if we had clearer guidelines about when to use scoped enums, and when not.

Scoped enums have some clear technical advantages (such as better type safety, thanks to no implicit conversion to int). And they sometimes result in better APIs when enum values don’t have to repeat the enum’s name in order to be clear.

But sometimes it’s also creating too much verbosity to use a scoped enum (ie. Qt::Orientation::Horizontal would perhaps not be an improvement).


Volker



More information about the Development mailing list