X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e67875d46730d8bf3f40f025d2ae6848f0bb47cf..c3afdfa7a603897d1fbca56e7d1705983038405e:/include/xbt/functional.hpp?ds=sidebyside diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index d9146a3f0a..e4ab77636a 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -205,27 +205,29 @@ public: } }; +template +class TaskImpl { +private: + F code_; + std::tuple args_; + typedef decltype(simgrid::xbt::apply(std::move(code_), std::move(args_))) result_type; +public: + TaskImpl(F code, std::tuple args) : + code_(std::move(code)), + args_(std::move(args)) + {} + result_type operator()() + { + return simgrid::xbt::apply(std::move(code_), std::move(args_)); + } +}; + template auto makeTask(F code, Args... args) -> Task< decltype(code(std::move(args)...))() > { - typedef decltype(code(std::move(args)...)) result_type; - - class Impl { - private: - F code_; - std::tuple args_; - public: - Impl(F code, std::tuple args) : - code_(std::move(code)), - args_(std::move(args)) {} - result_type operator()() - { - return simgrid::xbt::apply(std::move(code_), std::move(args_)); - } - }; - - return Impl(std::move(code), std::make_tuple(std::move(args)...)); + TaskImpl task(std::move(code), std::make_tuple(std::move(args)...)); + return std::move(task); } }