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

        1. concurrent.patch
          10 kB
          Matthew Woehlke
        2. qtconcurrent-blockingMapped-lambda.diff
          3 kB
          Thiago Macieira
        3. unacceptable_patch.diff
          7 kB
          Elvis Stansvik

        Issue Links

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

          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