Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-11-25 21:04:46


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().

Best,
John


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