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

QtConcurrent::run requires the return type to be default-constructible

    XMLWordPrintable

Details

    • All
    • 8
    • 642b9fce81b46e23b35b17e8284bd81bdba57fdd (qt/qtbase/dev) b91311c8bfa30ec02afb8027befff8943c8ff197 (qt/qtbase/6.2) 4d942551492378adaddca55cb1a48c11e7ec6a3a (qt/qtbase/6.1)
    • Qt6_Foundation_Sprint 40

    Description

      The issue is as simple as

      class X { public: X(int) { } };
      
      void f() {
         QFuture<X> x = QtConcurrent::run([]{ return X(0); });
      }
      

      It fails with a very long error message! In there we can find

      error: use of deleted function ‘QtConcurrent::RunFunctionTask<X>::RunFunctionTask()" ... "error: no matching function for call to ‘X::X()"

      Apparently, QtConcurrent::run wants to save the lambdas' return value in a member and later assign it, but if the value is not default constructible, that won't work!

      Attachments

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

        Activity

          People

            sonakur Sona Kurazyan
            jschaubzes Johannes Schaub
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes