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

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu May 4 18:13:05 CEST 2023

Il 04/05/23 09:10, Marc Mutz via Development ha scritto:
>> With the same trick that C++20 did for std::memory_order?
> That's an additional step we can take, but if clang-tidy has a
> modernize-scope-enums (or we could write it), then it would be
> preferable to just automatically port all users instead of writing code
> that keeps unported code running. The main issue isn't the scoping, the
> main issue will be the missing implicit conversion to underlying_type.

A few remarks:

* I think it's pretty optimistic to assume that people can/will use 
clang-based tooling on their codebases.

* This doesn't cope with an unspecified amount of other code -- thinking 
of .ui files, DBus XML interfaces, other serializations (QVariant?), 
etc. -- where the enumerators are currently written unscoped. We'd need 
a bunch of extra tools to fix all of that.

* Something doable in Qt 6 already: we need a QFlagsV2 that works across 
multiple enumerations (and that can use 8/16/32/64 bits, while at it), 
because we *still* have int-based APIs where one has to mix values from 
two or more enumerators.

My 2 c,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230504/dc8b1011/attachment.bin>

More information about the Development mailing list