0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 12:51:13 +08:00

Make the result_t::iterator::operator++(int) return void in order to fix a bug and preserve compatibility with C++20 ranges.

This commit is contained in:
MeanSquaredError 2024-08-31 14:08:08 +03:00 committed by Roland Bock
parent 5564584799
commit 0a2765d588

View File

@ -125,11 +125,16 @@ namespace sqlpp
return *this; 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; ++*this;
_result.next(_result_row.get());
return previous_it;
} }
std::reference_wrapper<db_result_t> _result; std::reference_wrapper<db_result_t> _result;