Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
netcards were renamed to netpoints recently
[simgrid.git] / include / xbt / functional.hpp
index 99cba0d..7596ef6 100644 (file)
@@ -78,7 +78,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)
@@ -114,11 +114,23 @@ private:
   struct whatever {};
 
   // Union used for storage:
+#if 0
   typedef typename std::aligned_union<0,
     void*,
     std::pair<void(*)(),void*>,
     std::pair<void(whatever::*)(), whatever*>
   >::type TaskUnion;
+#else
+  union TaskUnion {
+    void* ptr;
+    std::pair<void(*)(),void*> funcptr;
+    std::pair<void(whatever::*)(), whatever*> memberptr;
+    char any1[sizeof(std::pair<void(*)(),void*>)];
+    char any2[sizeof(std::pair<void(whatever::*)(), whatever*>)];
+    TaskUnion() {}
+    ~TaskUnion() {}
+  };
+#endif
 
   // Is F suitable for small buffer optimization?
   template<class F>
@@ -228,7 +240,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) {