diff --git a/include/sqlpp11/result.h b/include/sqlpp11/result.h index 58b0bd10..8c1bdae6 100644 --- a/include/sqlpp11/result.h +++ b/include/sqlpp11/result.h @@ -125,11 +125,16 @@ namespace sqlpp return *this; } - iterator operator++(int) + // It is quite difficult to implement a postfix increment operator that returns the old iterator + // because the underlying database results work in a stream fashion not allowing to return to + // previously-read rows. + // + // We need the postfix increment mostly for compatibility with C++20 ranges so we set the return + // type to "void" which is allowed for C++20 range iterators. + // + void operator++(int) { - auto previous_it = *this; - _result.next(_result_row.get()); - return previous_it; + ++*this; } std::reference_wrapper _result;