Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-99948

Fix enum/enum arithmetic in Qt

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: 5.15.8, 6.2.4, 6.3.0 Beta2
    • Fix Version/s: 5.15, 6.2.5, 6.3.1, 6.4.0 Beta1
    • Component/s: Core: Other
    • Labels:
      None
    • Story Points:
      8
    • Sprint:
      Team Two Foundation Sprint 50, Team Two Foundation Sprint 51, Team Two Foundation Sprint 52, Team B Foundation Sprint 53, Team B Foundation Sprint 55, Team B Foundation Sprint 56, Team B Foundation Sprint 57, Team B Foundation Sprint 58, Team B Foundation Sprint 59

      Description

      In C++, mixed enum-enum-arithmetic is deprecated since C++20. Unfortunately, we use it all over the place in Qt. Most of those cases relate to combining various flags. To future proof Qt, we need to address those.

      Currently, those are (if fixed at all) handled in a rather ad-hoc way. The most prominent example would be QKeyCombination, introducing a new class with a somewhat rich API  (key/keyboardModifiers/toCombined). In most other places, explicit casts to int are used.

       

      While a custom class might be warranted for public API, for internal flag handling this seems to be overkill. However, sprinkling casts or bespoke operator| all over the place is also not ideal. Thus, the idea is to create a new template, QFlagsV2 (name pending), which would have an API similar to QFlags, but supporting 2 or more different enums.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              mmutz Marc Mutz
              Reporter:
              fabiankosmale Fabian Kosmale
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: