KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 (stuff::iterator it = big_bunch_of_data.begin();it != big_bunch_of_data.end();it++) { do_stuff_with(*it); } Does it mean that by providing begin , end and operator++ , I could have the desired behavior ? And, what are these methods supposed to do ? I mean, can I make them lazy without breaking stuff ?
Tags (comma-separated)
Save Edits
Cancel