@@ -23,20 +23,29 @@ namespace kf
2323
2424 constexpr auto end ()
2525 {
26- return Iterator{ AsSentinel{}, std::ranges::end (m_base) };
26+ return Iterator{ std::ranges::end (m_base) };
2727 }
2828
2929 private:
30- struct AsSentinel
31- {
32- explicit AsSentinel () = default;
33- };
34-
35- struct Iterator
30+ class Iterator
3631 {
32+ private:
3733 using BaseIterator = std::ranges::iterator_t <Range>;
3834 std::array<BaseIterator, N> m_current{};
3935
36+ private:
37+ constexpr auto transformToTuple (const decltype (m_current)& arr) const
38+ {
39+ return arrayToTuple (arr, std::make_index_sequence<N>{});
40+ }
41+
42+ template <std::size_t ... I>
43+ constexpr auto arrayToTuple (const decltype (m_current)& arr, std::index_sequence<I...>) const
44+ {
45+ return std::tie ((*arr[I])...);
46+ }
47+
48+ public:
4049 constexpr Iterator (BaseIterator first, std::ranges::sentinel_t <Range> last)
4150 {
4251 m_current.front () = first;
@@ -47,7 +56,7 @@ namespace kf
4756 }
4857 }
4958
50- constexpr Iterator (AsSentinel, BaseIterator last)
59+ constexpr Iterator (BaseIterator last)
5160 {
5261 if constexpr (!std::ranges::bidirectional_range<Range>)
5362 {
@@ -64,17 +73,6 @@ namespace kf
6473 }
6574 }
6675
67- template <std::size_t ... I>
68- constexpr auto arrayToTuple (const decltype (m_current)& arr, std::index_sequence<I...>) const
69- {
70- return std::tie ((*arr[I])...);
71- }
72-
73- constexpr auto transformToTuple (const decltype (m_current)& arr) const
74- {
75- return arrayToTuple (arr, std::make_index_sequence<N>{});
76- }
77-
7876 constexpr auto operator *() const
7977 {
8078 return transformToTuple (m_current);
0 commit comments