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

When building for C++20 or newer, result_t::iterator is an std::input_iterator. Otherwise (C++17 or older) it is a LegacyInputIterator.

This commit is contained in:
MeanSquaredError 2024-09-02 20:20:58 +03:00 committed by Roland Bock
parent f983abcfc0
commit 633710aa93

View File

@ -81,7 +81,14 @@ namespace sqlpp
class iterator class iterator
{ {
public: public:
#if __cplusplus >= 202002L
using iterator_concept = std::input_iterator_tag;
#else
// LegacyInputIterator describes best our iterator's capabilities. However our iterator does not
// really fulfil the requirements for LegacyInputIterator because its post-increment operator
// returns void.
using iterator_category = std::input_iterator_tag; using iterator_category = std::input_iterator_tag;
#endif
using value_type = result_row_t; using value_type = result_row_t;
using pointer = const result_row_t*; using pointer = const result_row_t*;
using reference = const result_row_t&; using reference = const result_row_t&;
@ -133,10 +140,8 @@ namespace sqlpp
// It is quite difficult to implement a postfix increment operator that returns the old iterator // 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 // because the underlying database results work in a stream fashion not allowing to return to
// previously-read rows. // previously-read rows. That is why we set the post-increment return type to void, which is
// // allowed for C++20 input iterators
// 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) void operator++(int)
{ {