Tim Kuipers
Tim Kuipers

Reputation: 1764

Transform/map iterator<A> to iterator<B>

Suppose there is a function taking iterator<B> and I have some (iterable) collection of As.

void external_function(iterator<B> bit);

Furthermore I have a function to convert As to Bs.

B transform(A& a) { ... };

I would like some kind of wrapper iterator which iterates over all As and gives Bs instead.

iterator<B> transform(iterator<A> ait, UnaryOperator transformer);

Is there some function in boost that does that? Or do I have to write it myself?

Upvotes: 2

Views: 169

Answers (1)

tenfour
tenfour

Reputation: 36896

Boost has boost::transform_iterator; I suppose this is what you're looking for.

Upvotes: 3

Related Questions