Il 14/06/23 14:59, Marc Mutz via Development ha scritto:
A) new enums MUST have an explicit underlying type¹²

For unscoped enums, the compiler otherwise picks one, possibly resulting
in BiC when new addtions change the underlying type or otherwise just
warnings because one compiler uses a signed and the other an unsigned
type (most recent exmaple: QTBUG-113792). For scoped enums, the type is
int, but probably not always, and why require the reader of the code to
know the C++ rules when we can make it explicit?

By the way, the last sentence is not entirely correct. For scoped enums that don't specify otherwise, the underlying type is int, always. File under another advantage of using "enum class". Explicitly stating the underlying type for enum classes makes me actually wonder that there might be something tricky going on (e.g. the enum is being shoved into a bitfield or so). I'd rather just see "by default" `enum class Foo {`.

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@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

Attachment: smime.p7s
Description: Firma crittografica S/MIME

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to