55#include < memory>
66#include < ranges>
77
8- #include " IteratorBase.hpp"
98#include " Ref.hpp"
109#include " Result.hpp"
1110#include " internal/batch_size.hpp"
1514namespace sqlgen {
1615
1716// / An input_iterator that returns the underlying type.
18- template <class T >
17+ template <class T , class UnderlyingIteratorT >
1918class Iterator {
2019 public:
2120 using difference_type = std::ptrdiff_t ;
2221 using value_type = Result<T>;
2322
2423 struct End {
25- bool operator ==(const Iterator<T>& _it) const noexcept {
26- return _it == *this ;
27- }
24+ bool operator ==(const Iterator& _it) const noexcept { return _it == *this ; }
2825
29- bool operator !=(const Iterator<T>& _it) const noexcept {
30- return _it != *this ;
31- }
26+ bool operator !=(const Iterator& _it) const noexcept { return _it != *this ; }
3227 };
3328
34- Iterator (const Ref<IteratorBase >& _it)
29+ Iterator (const Ref<UnderlyingIteratorT >& _it)
3530 : current_batch_(get_next_batch(_it)), it_(_it), ix_(0 ) {}
3631
3732 ~Iterator () = default ;
@@ -46,7 +41,7 @@ class Iterator {
4641
4742 bool operator !=(const End& _end) const noexcept { return !(*this == _end); }
4843
49- Iterator<T> & operator ++() noexcept {
44+ Iterator& operator ++() noexcept {
5045 ++ix_;
5146 if (ix_ >= current_batch_->size () && !it_->end ()) {
5247 current_batch_ = get_next_batch (it_);
@@ -59,7 +54,7 @@ class Iterator {
5954
6055 private:
6156 static Ref<std::vector<Result<T>>> get_next_batch (
62- const Ref<IteratorBase >& _it) noexcept {
57+ const Ref<UnderlyingIteratorT >& _it) noexcept {
6358 using namespace std ::ranges::views;
6459 return _it->next (SQLGEN_BATCH_SIZE)
6560 .transform ([](auto str_vec) {
@@ -74,7 +69,7 @@ class Iterator {
7469 Ref<std::vector<Result<T>>> current_batch_;
7570
7671 // / The underlying database iterator.
77- Ref<IteratorBase > it_;
72+ Ref<UnderlyingIteratorT > it_;
7873
7974 // / The current index in the current batch.
8075 size_t ix_;
0 commit comments