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

Marco Bubke Marco.Bubke at qt.io
Thu May 4 09:58:52 CEST 2023


Hi Thiago

This is introducing dependencies on code which makes dependency breaking much harder. I very often need an enumeration in an interface but not the class itself. There are ways to get around that but it makes TDD harder if Qt is involved.

________________________________
From: Development <development-bounces at qt-project.org> on behalf of Thiago Macieira <thiago.macieira at intel.com>
Sent: Thursday, May 4, 2023 0:17
To: development at qt-project.org <development at qt-project.org>
Subject: Re: [Development] API style guide: scoped enum or not?

On Wednesday, 3 May 2023 10:51:18 PDT Jaroslaw Kobus via Development wrote:
> "enum class" has one advantage over "enum" inside a "class" : you may
> forward declare the "enum class", while the other not. That's quite often
> case that your header must include the other header just because you use
> the "enum" in "class" in your API and nothing more.

Hello Jarek

That's fair, but that requires a separate scope from the class itself. That
alone may be a reason not to do so, and instead just declare the enum inside
the class, as our current practice dictates, with the choice of plain enum or
enum class.
--
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230504/28d51c3d/attachment-0001.htm>


More information about the Development mailing list