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

QtConcurrent filter/map reduction data type requires a default constructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 6.1
    • Core: QtConcurrent
    • None
    • 8
    • 3d780c0d7068a6a6876d058314b1970810008c1f
    • Qt6_Foundation_Sprint 23

    Description

      When using QtConcurrent filter/map functions with a reduction, the type the reduction is performed in needs to have a default constructor. But when an initial value is passed in, there should not be a need for a default constructor.

      Reproducer:

       

      
      void tst_QtConcurrentFilterMapGenerated::test1()
      {
          /* test for
          template<typename typename ResultType, typename Sequence, typename MapFunctor, typename
          ReduceFunctor, typename reductionitemtype> ResultType blockingMappedReduced(QThreadPool* pool,
          const Sequence & sequence, MapFunctor function, ReduceFunctor reduceFunction, reductionitemtype
          && initialValue, ReduceOptions);
      
          with
            inputsequence=standard
            inputsequencepassing=lvalue
            inputitemtype=standard
            maptype=same
            mappeditemtype=standard
            reductiontype=different
            reductionitemtype=noconstruct
            mapfunction=functor
            mapfunctionpassing=lvalue
            reductionfunction=function
            reductionfunctionpassing=lvalue
            reductioninitialvaluepassing=lvalue
            reductionoptions=unspecified
          */
      
          QThreadPool pool;
          pool.setMaxThreadCount(1);
          auto input_sequence = []() {
              std::vector<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;
          }();
      
          auto map = MyMap<SequenceItem<tag_input>, SequenceItem<tag_input>> {};
          auto reductor = myReduce<SequenceItem<tag_input>, NoConstructSequenceItem<tag_reduction>>;
          auto initialvalue = NoConstructSequenceItem<tag_reduction>(0, true);
      
          auto result =
                  QtConcurrent::blockingMappedReduced(&pool, input_sequence, map, reductor, initialvalue);
      
          auto expected_result = NoConstructSequenceItem<tag_reduction>(42, true);
      
          QCOMPARE(result, expected_result);
      }
      
      

      Attachments

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

        Activity

          People

            ivan.solovev Ivan Solovev
            andreasbuhr Andreas Buhr
            Maurice Kalinowski Maurice Kalinowski
            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