This isn't a boost specific message per se, I guess, but I thought someone here may know the answer. I have a list<> of smart_ptrs. Some of the elements in the list are ready for processing under various circumstances. What I'd like would be a custom iterator that when I say "++i" it checks the element to see if it's ready, and if not, advance to the next, and so on until it finds a ready element. If it doesn't find one, then i == list.end(). This would simulate having a list that contained only ready elements, without having to have multiple lists. I have a number of books on C++, but I can't figure out from them how to create a custom iterator. Can anyone help? -- Colin Fox CF Consulting Inc. cfox@crystalcherry.com
This isn't a boost specific message per se, I guess, but I thought someone here may know the answer.
I have a list<> of smart_ptrs. Some of the elements in the list are ready for processing under various circumstances.
What I'd like would be a custom iterator that when I say "++i" it checks the element to see if it's ready, and if not, advance to the next, and so on until it finds a ready element. If it doesn't find one, then i == list.end(). This would simulate having a list that contained only ready elements, without having to have multiple lists.
This *is* a boost specific message! Try the filter_iterator_adaptor in the iterator_adaptors library. Cheers, George Heintzelman georgeh@aya.yale.edu
participants (2)
-
Colin Fox
-
George A. Heintzelman