Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Delete unusable default constructor.
[simgrid.git] / include / xbt / functional.hpp
index 4f5ca2c..9509d49 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -37,11 +37,10 @@ public:
   }
   void operator()() const
   {
-    const int argc                = args_->size();
     std::vector<std::string> args = *args_;
     std::vector<char*> argv(args.size() + 1); // argv[argc] is nullptr
     std::transform(begin(args), end(args), begin(argv), [](std::string& s) { return &s.front(); });
-    code_(argc, argv.data());
+    code_(static_cast<int>(args.size()), argv.data());
   }
 };
 
@@ -126,7 +125,7 @@ class Task<R(Args...)> {
     move_function move;
   };
 
-  TaskUnion buffer_;
+  TaskUnion buffer_         = {};
   const TaskVtable* vtable_ = nullptr;
 
   void clear()
@@ -168,7 +167,7 @@ public:
   }
 
 private:
-  template <class F> typename std::enable_if_t<canSBO<F>()> init(F code)
+  template <class F> typename std::enable_if_t<canSBO<F>()> init(F task_code)
   {
     const static TaskVtable vtable {
       // Call:
@@ -194,11 +193,11 @@ private:
         src_code->~F();
       }
     };
-    new(&buffer_) F(std::move(code));
+    new (&buffer_) F(std::move(task_code));
     vtable_ = &vtable;
   }
 
-  template <class F> typename std::enable_if_t<not canSBO<F>()> init(F code)
+  template <class F> typename std::enable_if_t<not canSBO<F>()> init(F task_code)
   {
     const static TaskVtable vtable {
       // Call:
@@ -216,7 +215,7 @@ private:
       // Move:
       nullptr
     };
-    *reinterpret_cast<F**>(&buffer_) = new F(std::move(code));
+    *reinterpret_cast<F**>(&buffer_) = new F(std::move(task_code));
     vtable_ = &vtable;
   }