Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Misc Sonar issues.
[simgrid.git] / src / xbt / utils / iter / variable_for_loop.hpp
index 75c4b54..cbcb0a2 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     if (has_effect and (not collections.empty())) {
       std::transform(collections.begin(), collections.end(), std::back_inserter(current_subset),
-                     [](const auto& c) { return c.get().begin(); });
+                     [](const auto& c) { return c.get().cbegin(); });
       underlying_collections = std::move(collections);
     }
     // Otherwise leave `underlying_collections` as default-initialized (i.e. empty)
@@ -85,12 +85,12 @@ template <typename IterableType> void variable_for_loop<IterableType>::increment
 
   for (auto j = k; j != std::numeric_limits<size_t>::max(); j--) {
     // Attempt to move to the next element of the `j`th collection
-    const auto& new_position = ++current_subset[j];
+    ++current_subset[j];
 
     // If the `j`th element has reached its own end, reset it
     // back to the beginning and keep moving forward
-    if (new_position == underlying_collections[j].get().end()) {
-      current_subset[j] = underlying_collections[j].get().begin();
+    if (current_subset[j] == underlying_collections[j].get().cend()) {
+      current_subset[j] = underlying_collections[j].get().cbegin();
     } else {
       // Otherwise we've found the largest element which needed to
       // be moved down. Everyone else before us has been reset