[Development] Proposing to change https://wiki.qt.io/API_Design_Principles#Enums_in_classes to require scoped enums

Allan Sandfeld Jensen kde at carewolf.com
Mon Jan 20 12:34:33 CET 2025


On Friday 17 January 2025 22:52:04 Central European Standard Time Marc Mutz 
via Development wrote:
> On 17.01.25 16:52, Allan Sandfeld Jensen wrote:
> > Did anyone ever suggest or put pressure on the C++ standard committee to
> > add strong unscoped enums?
> 
> Someone did:
> 
> // https://gcc.godbolt.org/z/69zWsoGP9
>      enum class Strong { One, Two, Three };
>   #ifdef __cpp_using_enum
>      using enum Strong;
>   #else
>      inline constexpr auto One = Strong::One;
>      inline constexpr auto Two = Strong::Two;
>      inline constexpr auto Three = Strong::Three;
>   #endif
>      use(One); use(Two); use(Three);
> 
> The ice for unscoped enums becomes _very_ thin.

Sure, when we can ask users to depend on C++20

Best regards
Allan






More information about the Development mailing list