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

QtConcurrent and functor by reference

    XMLWordPrintable

Details

    Description

      We can't use functors by reference in QtConcurrent. For example like this:

      QFuture<void> future = QtConcurrent::map<IteratorType, ClassType&>(begin, end, (ClassType&)*this);
      

      Because of loosing type information, QtConcurrent use a copy of functor. Sometimes it's not useful.

      We loose type information in next string (qtconcurrentmap.h line 122):

      template <typename Iterator, typename MapFunctor>
      QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
      {
          return startMap(begin, end, map);
      }
      

      Solution is to specify types directly instead of find out them from function parameters:

      template <typename Iterator, typename MapFunctor>
      QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
      {
          return startMap<Iterator, MapFunctor>(begin, end, map);
      }
      

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            acteon Max
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes