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

QtConcurrent::mapped doesn't work with C++11 lambdas

    XMLWordPrintable

Details

    • All
    • 13
    • Qt6_Foundation_ Sprint 4, Qt6_Foundation_ Sprint 5, Qt6_Foundation_ Sprint 6

    Description

      QtConcurrent::mapped currently supports function pointers, pointer to member-functions, and functors which define a nested typedef result_type as map and reduce functions. Lambda expressions don't have that typedef, so compilation fails.

      Workaround: stateless lambdas decay into function pointers, so you use the dereference operator to make them into function references, which again decay to function pointers, to force a function pointer deduction:
      <code>
      auto result = QtConcurrent::blockingMapped(someList, *[=](ListItem item)

      { return QString(""); }

      );
      </code>

      QtConcurrent should not require result_type nested typedefs.

      Attachments

        Issue Links

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

          Activity

            People

              heimrich Karsten Heimrich
              kimi arthur Kimi Arthur
              Maurice Kalinowski Maurice Kalinowski
              Alex Blasche Alex Blasche
              Votes:
              12 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes