X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cdf6a962eb4e88efbed3df9c41343adabcf09e6c..a96793ec8c496eec19daf68f3aa0c4eded2ea166:/include/xbt/functional.hpp diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 386830b637..1fefcd8473 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -27,7 +27,6 @@ namespace simgrid { namespace xbt { template class MainFunction { -private: F code_; std::shared_ptr> args_; @@ -109,8 +108,6 @@ template class Task; */ template class Task { -private: - // Placeholder for some class type: struct whatever {}; @@ -189,14 +186,13 @@ public: } private: - template typename std::enable_if()>::type init(F code) { const static TaskVtable vtable { // Call: - [](TaskUnion& buffer, Args... args) { + [](TaskUnion& buffer, Args&&... args) { F* src = reinterpret_cast(&buffer); F code = std::move(*src); src->~F(); @@ -225,7 +221,7 @@ private: { const static TaskVtable vtable { // Call: - [](TaskUnion& buffer, Args... args) { + [](TaskUnion& buffer, Args&&... args) { // Delete F when we go out of scope: std::unique_ptr code(*reinterpret_cast(&buffer)); return (*code)(std::forward(args)...); @@ -248,7 +244,7 @@ public: operator bool() const { return vtable_ != nullptr; } bool operator!() const { return vtable_ == nullptr; } - R operator()(Args... args) + R operator()(Args&&... args) { if (vtable_ == nullptr) throw std::bad_function_call(); @@ -260,7 +256,6 @@ public: template class TaskImpl { -private: F code_; std::tuple args_; typedef decltype(simgrid::xbt::apply(std::move(code_), std::move(args_))) result_type;