Commit 1f8e5bd3 authored by Eike Ziller's avatar Eike Ziller

runAsync: Use universal references again

We don't use std::thread anymore, so we don't need to avoid universal
references in the called function. (std::thread with MSVC2013 does not
correctly forward the function arguments.)

Change-Id: I2a2fb0bd9b4cfcfe47baecb0b53d78e67f97f442
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent be82a24a
......@@ -517,27 +517,22 @@ void blockingMapReduce(QFutureInterface<ReduceResult> futureInterface, const Con
futureInterface.reportFinished();
}
// TODO: Use universal references and std::forward to function when we require MSVC2015
// (MSVC2013 has a bug that std::thread does not move the copied arguments to the function call,
// which leads to compile errors with rvalue arguments)
template <typename ResultType, typename Function, typename Obj, typename... Args>
typename std::enable_if<std::is_member_pointer<typename std::decay<Function>::type>::value>::type
runAsyncImpl(QFutureInterface<ResultType> futureInterface, const Function &function, const Obj &obj, const Args&... args)
runAsyncImpl(QFutureInterface<ResultType> futureInterface, Function &&function, Obj &&obj, Args&&... args)
{
std::mem_fn(function)(obj, futureInterface, args...);
std::mem_fn(std::forward<Function>(function))(std::forward<Obj>(obj),
futureInterface, std::forward<Args>(args)...);
if (futureInterface.isPaused())
futureInterface.waitForResume();
futureInterface.reportFinished();
}
// TODO: Use universal references and std::forward to function when we require MSVC2015
// (MSVC2013 has a bug that std::thread does not move the copied arguments to the function call,
// which leads to compile errors with rvalue arguments)
template <typename ResultType, typename Function, typename... Args>
typename std::enable_if<!std::is_member_pointer<typename std::decay<Function>::type>::value>::type
runAsyncImpl(QFutureInterface<ResultType> futureInterface, const Function &function, const Args&... args)
runAsyncImpl(QFutureInterface<ResultType> futureInterface, Function &&function, Args&&... args)
{
function(futureInterface, args...);
function(futureInterface, std::forward<Args>(args)...);
if (futureInterface.isPaused())
futureInterface.waitForResume();
futureInterface.reportFinished();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment