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

qfloat16 comparison with integral types is ambiguous

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.7.0 FF
    • 6.5, 6.6
    • Core: Other
    • None
    • All
    • 3
    • 0d85d0a72 (dev)
    • Foundations Sprint 94, Foundations Sprint 95, Foundations Sprint 96, Foundations Sprint 97

    Description

      qfloat16 explicitly implements all relational operators for comparing with various FP types (float, double, long double), but for integral types it provides only operators for comparison with int.

      As a result, code like that will fail to compile:

      qfloat16 f16 = 1.0;
      int i = 1;
      qint64 i64 = 1;
      
      qDebug() << (f16 == i); // fine, we have explicit operator==(qfloat16, int)
      qDebug() << (f16 == i64); // ERROR: ambiguity
      

      This is discovered while working on C++20 comparison story, but this is a pre-existing problem.

      So, should we provide comparison operator overloads for all integral types (signed and unsigned)?

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-117637
          # Subject Branch Project Status CR V

          Activity

            People

              ivan.solovev Ivan Solovev
              ivan.solovev Ivan Solovev
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes