[Development] API style guide: scoped enum or not?
Marc Mutz
marc.mutz at qt.io
Thu Jan 16 13:55:56 CET 2025
On 05.05.23 08:10, Thiago Macieira wrote:
> On Thursday, 4 May 2023 22:48:44 PDT Thiago Macieira wrote:
>> On Thursday, 4 May 2023 22:28:44 PDT Thiago Macieira wrote:
>>> But for those that use a very name, the API becomes cumbersome:
>>> Qt::Alignment al = Qt::AlignmentFlag::Left;
>>>
>>> Can we do better? With C++20 using enum (GCC 11, Clang 13, so not in my
>>> proposal) we could easily.
>>
>> Actually, we can leave that as an optional feature for GCC 10 and Clang 10,
>> if we choose those as our minima. We wouldn't be able to use the used
>> enumerations in our code until the feature became mandatory, but users
>> whose compilers do support the feature could use it.
>>
>> https://codereview.qt-project.org/c/qt/qtbase/+/476084
>
> Scratch that. This doesn't work and I don't know why:
> https://gcc.godbolt.org/z/6jf7Ebecq
>
> Looks like the using enum feature is not very useful for us. Back to the
> drawing board for scoped flags
https://gcc.godbolt.org/z/6exEonP5o, maybe?
--
Marc Mutz <marc.mutz at qt.io> (he/his)
Principal Software Engineer
The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B
More information about the Development
mailing list