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

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

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Issue Links

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

          Activity

            People

              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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes