Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
attempt to get rid of all const_cast (take 2)
[simgrid.git] / include / xbt / functional.hpp
index 2429b5b..10c16bf 100644 (file)
@@ -39,11 +39,12 @@ public:
   {}
   void operator()() const
   {
+    char noarg[] = {'\0'};
     const int argc = args_->size();
     std::vector<std::string> args = *args_;
     std::unique_ptr<char*[]> argv(new char*[argc + 1]);
     for (int i = 0; i != argc; ++i)
-      argv[i] = args[i].empty() ? const_cast<char*>(""): &args[i].front();
+      argv[i] = args[i].empty() ? noarg : &args[i].front();
     argv[argc] = nullptr;
     code_(argc, argv.get());
   }
@@ -78,7 +79,7 @@ constexpr auto apply(F&& f, Tuple&& t, simgrid::xbt::index_sequence<I...>)
  *
  *  auto args = std::make_tuple(1, false);
  *  int res = apply(foo, args);
- *  @encode
+ *  @endcode
  **/
 template <class F, class Tuple>
 constexpr auto apply(F&& f, Tuple&& t)
@@ -240,7 +241,7 @@ private:
       [](TaskUnion& buffer, Args... args) -> R {
         // Delete F when we go out of scope:
         std::unique_ptr<F> code(*reinterpret_cast<F**>(&buffer));
-        (*code)(std::forward<Args>(args)...);
+        return (*code)(std::forward<Args>(args)...);
       },
       // Destroy:
       [](TaskUnion& buffer) {