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

qfloat16 comparison with integral types is ambiguous

XMLWordPrintable

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

      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)?

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

            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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes