SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.37k stars 472 forks source link

rowset can not get size #1083

Closed xum07 closed 9 months ago

xum07 commented 9 months ago

rowset support get size by std::distance. However, if calculate the size by std::distance first, then the rowset begin iterator can not point to expected beginning any more. Just like the following code:

rowset<row> rows = (sess.prepare << "select * from mytable");  // assume there are 10 rows
cout << std::distance(rows.begin(), rows.end())<< endl; // here is 10
cout << std::distance(rows.begin(), rows.end())<< endl; // here is 0
vadz commented 9 months ago

rowset_iterator is an input iterator, so of course it can't be iterated more than once -- so what you see is perfectly normal.