The iota template function was added to the standard library to fill an iterator range with an increasing sequence of values.
template<typename ForwardIterator, typename Tp>
void
iota(ForwardIterator first, ForwardIterator last, Tp value)
{
for (; first != last; ++first)
{
*first = value;
++value;
}
}
Most other templates in <numeric>
have versions that accept user-specified operators.
Having this:
template<typename ForwardIterator, typename Tp, typename Operator>
void
iota(ForwardIterator first, ForwardIterator last, Tp value, Operator op)
{
for (; first != last; ++first)
{
*first = value;
op(value);
}
}
would be convenient if you don't want to (or can't) overload operator++() for Tp. I would find this version more widely usable than the default operator++() version. <