Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New method: MutexImpl::is_granted()
[simgrid.git] / src / xbt / utils / iter / subsets.hpp
index 1abea21900f9c54daa138d330d05ddaf407b1b3b..ec3cac83778e2164239c5f18d60757c55b06b85f 100644 (file)
@@ -73,7 +73,7 @@ subsets_iterator<Iterator>::subsets_iterator(unsigned k, Iterator begin, Iterato
 
 template <typename Iterator> bool subsets_iterator<Iterator>::equal(const subsets_iterator<Iterator>& other) const
 {
-  if (this->end == std::nullopt and other.end == std::nullopt) {
+  if (this->end == std::nullopt && other.end == std::nullopt) {
     return true;
   }
   if (this->k != other.k) {
@@ -82,7 +82,7 @@ template <typename Iterator> bool subsets_iterator<Iterator>::equal(const subset
   if (this->k == 0) { // this->k == other.k == 0
     return true;
   }
-  return this->end != std::nullopt and other.end != std::nullopt and this->P[0] == other.P[0];
+  return this->end != std::nullopt && other.end != std::nullopt && this->P[0] == other.P[0];
 }
 
 template <typename Iterator> const std::vector<Iterator>& subsets_iterator<Iterator>::dereference() const
@@ -103,14 +103,13 @@ template <typename Iterator> void subsets_iterator<Iterator>::increment()
   ++current_subset[k - 1];
   ++P[k - 1];
 
-  const auto end                  = this->end.value();
-  const bool shift_other_elements = current_subset[k - 1] == end;
+  const bool shift_other_elements = current_subset[k - 1] == end.value();
 
   if (shift_other_elements) {
     if (k == 1) {
       // We're done in the case that k = 1; here, we've iterated
       // through the list once, which is all that is needed
-      this->end = std::nullopt;
+      end = std::nullopt;
       return;
     }
 
@@ -150,7 +149,7 @@ template <typename Iterator> void subsets_iterator<Iterator>::increment()
     // element can be located. Thus, if `P[0] > (n - k)`, this means
     // we've sucessfully iterated through all subsets so we're done
     if (P[0] > (n - k)) {
-      this->end = std::nullopt;
+      end = std::nullopt;
       return;
     }