I have a class that hands out a sequence of Things through a getNextThing() interface, ie.,
struct Thing { };
struct ThingFeed { Thing * getNextThing( ); };
returning null when there's no more things. I'd like to be able to feed this into the Boost range-based algorithms, something like
Since we are not in a position to offer range primitives, there is more work required than one would like. To maximize interoperability with algorithms and existing C++ code the ranges in Boost.Range are limited to being implemented on top of iterators. Therefore the getNextThing() would need to be part of an increment operator / operators upon a forward traversal iterator. This is not difficult to implement using Boost.Iterator.
Here's how you might do such a thing (untested):
class ThingIterator : public boost::iterator_facade