How could I make my own lazy iterator?
问题 I'm making a C++11 class that produces a huge amount of data. That data currently comes from a database and it cannot fit entirely in memory. I would like to provide the user with an iterator that behaves like regular STL iterators, but that would be lazy. More precisely, I would be able to do something like that : for (auto& item : big_bunch_of_data) { do_stuff_with(item); } With item being retrieved from the database only at each iteration. If I'm right, this new syntax is sugar for for