]> AND Public Git Repository - simgrid.git/blobdiff - src/xbt/utils/iter/LazyKSubsets.hpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / xbt / utils / iter / LazyKSubsets.hpp
index 0164e0d5b2d948768faf055d0f80d5ccac0057be..e9773d15824919877dddc1796b7b5fb3c265765f 100644 (file)
@@ -10,7 +10,7 @@
 
 namespace simgrid::xbt {
 
-template <class Iterable> class LazyKSubsets<Iterable>;
+template <class Iterable> class LazyKSubsets;
 template <class Iterable> LazyKSubsets<Iterable> make_k_subsets_iter(unsigned k, const Iterable& container);
 
 /**
@@ -27,14 +27,19 @@ template <class Iterable> LazyKSubsets<Iterable> make_k_subsets_iter(unsigned k,
  */
 template <class Iterable> class LazyKSubsets final {
 public:
-  auto begin() const { return subsets_iterator<Iterable::iterator>(k, iterable.begin(), iterable.end()); }
-  auto end() const { return subsets_iterator<Iterable::iterator>(k); }
+  auto begin() const
+  {
+    return subsets_iterator<typename Iterable::const_iterator>(k, iterable.begin(), iterable.end());
+  }
+  auto end() const { return subsets_iterator<typename Iterable::const_iterator>(k); }
 
 private:
   const unsigned k;
   const Iterable& iterable;
   LazyKSubsets(unsigned k, const Iterable& iterable) : k(k), iterable(iterable) {}
-  friend LazyKSubsets<Iterable> make_k_subsets_iter(unsigned k, const Iterable& iterable);
+
+  template <class IterableType>
+  friend LazyKSubsets<IterableType> make_k_subsets_iter(unsigned k, const IterableType& iterable);
 };
 
 template <class Iterable> LazyKSubsets<Iterable> make_k_subsets_iter(unsigned k, const Iterable& container)