Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QtConcurrent (map, mapped) without c++11

    General and Desktop
    qtconcurrent c++11
    2
    2
    1798
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • shavera
      shavera last edited by shavera

      So far, in order to implement QtConcurrent::map, and QtConcurrent::mapped, I've had to use lambdas or std::function objects. It's working okay, but it seems a bit strange when so much of Qt is indifferent to c++11 at best (one can argue it bumps a little against the standard here and there)

      examples:

      {
      // in some class, making use of its member variables m_bar
      QList<double> fooList {.. initialized ..};
      auto future QtConcurrent::map(fooList, [this](double& foo){
          foo = this->doStuff(m_bar, foo);
      });
      }
      

      in the mapped case, it couldn't detect a return_type for the lambda, so one could wrap a lambda in a std::function or bind it directly

      {
      QList<double> fooList{};
      
      using std::placeholders::_1;
      auto calc_F = std::bind(&MyClass::doStuff, this, _1);
      
      auto future = QtConcurrent(fooList, calc_F);
      }
      

      I'd suggest adding these kind of constructions into the documentation, given their utility.

      But what other ways might one use member functions within QtConcurrent? The examples provided make use of global functions which are a little trivial to extend.

      JKSH 1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators @shavera last edited by

        @shavera said:

        I'd suggest adding these kind of constructions into the documentation, given their utility.

        They are :-) Scroll to the bottom of http://doc.qt.io/qt-5/qtconcurrentmap.html

        But what other ways might one use member functions within QtConcurrent? The examples provided make use of global functions which are a little trivial to extend.

        See the same link

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 0
        • First post
          Last post