Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-26 08:43:50


John Torjo <john.lists_at_[hidden]> writes:

> David Abrahams wrote:
>> "Walker, Daniel" <Daniel.Walker_at_[hidden]> writes:
>>
>>>template <class T, class Size>
>>>inline T next_n(T x, Size n)
>>>{
>>> std::advance(x, n);
>>> return x;
>>>}
>>>
>>>template <class T, class Size>
>>>inline T prior_n(T x, Size n)
>>>{
>>> std::advance(x, -n);
>>> return x;
>>>}
>>>
>> [...]
>> Seems reasonable to me, though I'd tend to call them next and prior.
>>
>
> Indeed, there are different overloads.
> So if you want next(iterator) it increments (by one), and if you need
> a specific size, just use next(iterator,size).
>
> Same goes for prior().

Daniel, if you submit implementation, doc, and test patches I'd be
happy to apply them. I've definitely wanted this capability myself a
few times.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk