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

QPromise: Can't use addResult() with initializer list

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.6.0
    • 6.2.0
    • Core: QtConcurrent
    • None
    • 3
    • f8dba0395 (dev)
    • Foundation Sprint 78

      The following code fails to compile:

      struct MyClass
      {
          QString strValue;
          int intValue = 0;
      };
      
      void foo()
      {
          QPromise<MyClass> myPromise;
          myPromise.addResult({"bar", 1});
      }
      

      The error is:

      error: no matching function for call to ‘QPromise<MyClass>::addResult(<brace-enclosed initializer list>)’
      In member function ‘void foo()’:
      error: no matching function for call to ‘QPromise<MyClass>::addResult(<brace-enclosed initializer list>)’
         |     myPromise.addResult({"foo", 1});
         |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
      

      I'm forced to do:

      myPromise.addResult(MyClass{"bar", 1});
      

      what shouldn't be really necessary.

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

            mmutz Marc Mutz
            jkobus Jarek Kobus
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes