QtConcurrent (map, mapped) without c++11
-
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.
-
@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