Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Assignment operators should return non-"const" references (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 11 Apr 2023 13:26:28 +0000 (15:26 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 11 Apr 2023 13:26:28 +0000 (15:26 +0200)
Also enfore C++ "rule-of-three".

src/mc/api/strategy/BasicStrategy.hpp
src/mc/api/strategy/Strategy.hpp
src/mc/api/strategy/WaitStrategy.hpp

index 93ebd6c..80b7dc3 100644 (file)
@@ -11,9 +11,12 @@ namespace simgrid::mc {
 /** Basic MC guiding class which corresponds to no guide at all (random choice) */
 class BasicStrategy : public Strategy {
 public:
-  void operator=(const BasicStrategy&)
+  BasicStrategy()                     = default;
+  ~BasicStrategy()                    = default;
+  BasicStrategy(const BasicStrategy&) = delete;
+  BasicStrategy& operator=(const BasicStrategy&)
   { /* nothing to copy over while cloning */
-    return;
+    return *this;
   }
 
   std::pair<aid_t, int> next_transition() const override
index ef5b87f..a530789 100644 (file)
@@ -17,10 +17,12 @@ protected:
   std::map<aid_t, ActorState> actors_to_run_;
 
 public:
-  virtual ~Strategy()                                      = default;
-  void operator=(const Strategy&)
+  Strategy()                = default;
+  virtual ~Strategy()       = default;
+  Strategy(const Strategy&) = delete;
+  Strategy& operator=(const Strategy&)
   { /* nothing to copy over while cloning */
-    return;
+    return *this;
   }
 
   virtual std::pair<aid_t, int> next_transition() const = 0;
index ae54912..182411e 100644 (file)
@@ -17,7 +17,14 @@ class WaitStrategy : public Strategy {
   bool taking_wait_ = false;
 
 public:
-  void operator=(const WaitStrategy& guide) { taken_wait_ = guide.taken_wait_; }
+  WaitStrategy()                     = default;
+  ~WaitStrategy()                    = default;
+  WaitStrategy(const BasicStrategy&) = delete;
+  WaitStrategy& operator=(const WaitStrategy& guide)
+  {
+    taken_wait_ = guide.taken_wait_;
+    return *this;
+  }
 
   bool is_transition_wait(Transition::Type type) const
   {