Skip to content

Commit 87cda7c

Browse files
committed
uses IterToolFn in enumerate
1 parent 3a8f11d commit 87cda7c

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

enumerate.hpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ namespace iter {
1313
namespace impl {
1414
template <typename Container>
1515
class Enumerable;
16-
struct EnumerateFn;
16+
17+
using EnumerateFn = IterToolFn<Enumerable>;
1718
}
19+
constexpr impl::EnumerateFn enumerate;
1820
}
1921

2022
template <typename Container>
@@ -29,7 +31,7 @@ class iter::impl::Enumerable {
2931
using BasePair = std::pair<std::size_t, iterator_deref<Container>>;
3032

3133
// Value constructor for use only in the enumerate function
32-
Enumerable(Container&& in_container, std::size_t in_start)
34+
Enumerable(Container&& in_container, std::size_t in_start = 0)
3335
: container(std::forward<Container>(in_container)), start{in_start} {}
3436

3537
public:
@@ -94,22 +96,4 @@ class iter::impl::Enumerable {
9496
}
9597
};
9698

97-
struct iter::impl::EnumerateFn : iter::impl::Pipeable<EnumerateFn> {
98-
template <typename Container>
99-
Enumerable<Container> operator()(
100-
Container&& container, std::size_t start=0) const {
101-
return {std::forward<Container>(container), start};
102-
}
103-
104-
template <typename T>
105-
Enumerable<std::initializer_list<T>> operator()(
106-
std::initializer_list<T> il, std::size_t start=0) const {
107-
return {std::move(il), start};
108-
}
109-
};
110-
111-
namespace iter {
112-
constexpr impl::EnumerateFn enumerate;
113-
}
114-
11599
#endif

0 commit comments

Comments
 (0)