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

QtConcurrent filter/map does not work with move-only output sequences

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.0
    • Core: QtConcurrent
    • None

    Description

      While QtConcurrent map/filter functions can work with move-only input sequences, they cannot work with move-only output sequences. This implies that copyable output sequences are copied, even though there is no fundamental reason to do so.

      Note that this Jira-Item is about copyable items in move-only containers. It is not about move-only items.

      Reproducer:

      void tst_QtConcurrentFilterMapGenerated::test1()
      {
          /* test for
          template<typename OutputSequence, typename InputSequence, typename MapFunctor>
          OutputSequence blockingMapped(QThreadPool* pool, InputSequence && sequence, MapFunctor
          function);
      
          with
            inputsequence=moveonly
            inputsequencepassing=rvalue
            inputitemtype=standard
            outputsequence=moveonly
            maptype=same
            mappeditemtype=standard
            mapfunction=functor
            mapfunctionpassing=lvalue
          */
      
          QThreadPool pool;
          pool.setMaxThreadCount(1);
      
          auto map = MyMap<SequenceItem<tag_input>, SequenceItem<tag_input>> {};
      
          auto result = QtConcurrent::blockingMapped(
                  &pool,
                  []() {
                      MoveOnlyVector<SequenceItem<tag_input>> result;
                      result.push_back(SequenceItem<tag_input>(1, true));
                      result.push_back(SequenceItem<tag_input>(2, true));
                      result.push_back(SequenceItem<tag_input>(3, true));
                      result.push_back(SequenceItem<tag_input>(4, true));
                      result.push_back(SequenceItem<tag_input>(5, true));
                      result.push_back(SequenceItem<tag_input>(6, true));
                      return result;
                  }(),
                  map);
      
          auto expected_result = []() {
              MoveOnlyVector<SequenceItem<tag_input>> result;
              result.push_back(SequenceItem<tag_input>(2, true));
              result.push_back(SequenceItem<tag_input>(4, true));
              result.push_back(SequenceItem<tag_input>(6, true));
              result.push_back(SequenceItem<tag_input>(8, true));
              result.push_back(SequenceItem<tag_input>(10, true));
              result.push_back(SequenceItem<tag_input>(12, true));
              return result;
          }();
      
          QCOMPARE(result, expected_result);
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              cnn Qt Core & Network
              andreasbuhr Andreas Buhr
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes