X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8f2e8075d660a354a3aabf065998f42802f9cc11..c3afdfa7a603897d1fbca56e7d1705983038405e:/include/xbt/functional.hpp diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 1f8abfbb20..e4ab77636a 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -178,7 +178,7 @@ private: Impl(F&& code) : code_(std::move(code)) {} Impl(F const& code) : code_(code) {} ~Impl() override {} - R operator()(Args... args) + R operator()(Args... args) override { return code_(std::forward(args)...); } @@ -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); } }