Boost logo

Boost :

Subject: [boost] [iterator] Interest check in specialized reproduction_iterator
From: Christoph Heindl (christoph.heindl_at_[hidden])
Date: 2009-11-17 11:55:29

Good afternoon,

Would there be interest in adding a specialized iterator, called
reproduction_iterator, that allows specifying a single element which
is iterated n-times.


const std::vector<int> values = boost::assign::list_of(1)(2)(3)(5);
const int c = 3;
std::vector<int> result;

  extboost::make_reproduction_iterator(c, values.size()),

// result contains 3, 6, 9, 15

The rationale for implementing the iterator is to provide a mechanism
for the cheap iteration over a 'sequence' of equal objects. This is
used (in my case) for adaption of functions that otherwise take two
ranges and where I can bind one range to a single object.

In the example above one can achieve the same effect by using a binder
and std::transform that takes a single range. This is IMHO not always

'reproduction_iterator' is implemented as random access iterator using

Best regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at