99#include < initializer_list>
1010#include < type_traits>
1111
12-
13- // enumerate functionality for python-style for-each enumerate loops
14- // for (auto e : enumerate(vec)) {
15- // std::cout << e.index
16- // << ": "
17- // << e.element
18- // << '\n';
19- // }
20-
21-
2212namespace iter {
2313
2414 // Forward declarations of Enumerable and enumerate
@@ -50,9 +40,9 @@ namespace iter {
5040 Enumerable (Container&& in_container)
5141 : container(std::forward<Container>(in_container))
5242 { }
53-
43+
5444 public:
55- // "yielded" by the Enumerable::Iterator. Has a .index, and a
45+ // "yielded" by the Enumerable::Iterator. Has a .index, and a
5646 // .element referencing the value yielded by the subiterator
5747 class IterYield : public BasePair {
5848 public:
@@ -74,13 +64,13 @@ namespace iter {
7464 Iterator (iterator_type<Container>&& si)
7565 : sub_iter{std::move (si)},
7666 index{0 }
77- { }
67+ { }
7868
7969 IterYield operator *() {
8070 return {this ->index , *this ->sub_iter };
8171 }
8272
83- Iterator& operator ++() {
73+ Iterator& operator ++() {
8474 ++this ->sub_iter ;
8575 ++this ->index ;
8676 return *this ;
@@ -116,11 +106,10 @@ namespace iter {
116106 return {std::forward<Container>(container)};
117107 }
118108
119- // for initializer lists. copy constructs the list into the Enumerable
120109 template <typename T>
121110 Enumerable<std::initializer_list<T>> enumerate(
122111 std::initializer_list<T> il)
123- {
112+ {
124113 return {std::move (il)};
125114 }
126115}
0 commit comments