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

QFuture<T> cannot be passed to a method expecting QFuture<void>

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.11.0 FF
    • 6.9.2
    • Core: QtConcurrent
    • None
    • 0f20882c4 (dev), f247a3d59 (6.10)

      The documentation says any QFuture<T> can be assigned to QFuture<void> and while this works in an explicit assignment, it does not when an argument expect QFuture<void> because the constructor that takes a QFuture<T> and build a QFuture<void> is explicit:

         template<typename U, typename V = T, typename = QtPrivate::EnableForVoid<V>>
          explicit QFuture(const QFuture<U> &other) : d(other.d)
          {
          } 

      Attached is a test case, uncomment line 34 to see the error:

      qfuture/main.cpp:34:23: error: invalid initialization of reference of type ‘const QFuture<void>&’ from expression of type ‘QFuture<long long int>’
         34 |         debugProgress(future); // fails to compile

        1. qfuture.tar.gz
          0.8 kB
          Andras Mantia
        For Gerrit Dashboard: QTBUG-139790
        # Subject Branch Project Status CR V

            cnn Qt Core & Network
            andras@kdab.com Andras Mantia
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change