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

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

XMLWordPrintable

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

      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.

        1. qtconcurrent-blockingMapped-lambda.diff
          3 kB
          Thiago Macieira
        2. unacceptable_patch.diff
          7 kB
          Elvis Stansvik
        3. concurrent.patch
          10 kB
          Matthew Woehlke
        For Gerrit Dashboard: QTBUG-33735
        # Subject Branch Project Status CR V

            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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes