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

QFuture::unwrap() doesn't support non-copyable types

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.7.2
    • Core: QtConcurrent
    • None

      While QFuture is generally designed to support move-only types, using unwrap() on a (nested) future holding a move-only type fails to compile. The code inside QFuture::unwrap() is quite clear in its expectation of the result type copyability:

                  // ...

                  nestedFuture.then([promise] (const QFuture<NestedType> &nested) mutable { // <- passing `nested` by const&

                      // ...

                      {

                          if constexpr (!std::is_void_v<NestedType>)
                              promise.reportResults(nested.results()); // <- calling results() that copies the stored QList

                                            }

      Though QFuture::takeResults() to move the entire underlying QList might be too much to add (might it?), at least unwrap() could make a new QList and std::move() each result in that new list if it detects move-only result type.

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

            cnn Qt Core & Network
            alexey.rusakov Alexey Rusakov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes