Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2003-04-28 10:20:04


--- At Fri, 25 Apr 2003 17:01:56 -0400, Vincent LaBella wrote:

>Hello,
> I'm using boost::tokenizer and want to goto the last token in the
>sequence, so I tried
>
>Tok::iterator last = tok.end();
>last--; // error decrement not defined
>
>last = tok.begin();
>advance(last,tok.size()-1); // error size() not defined.
>
>Is it possible to add decrement or a back() reference to tokenizer?

Probably not. The iterator is a likely a forward iterator (I havent
looked at the code). Forward iterators typically have valid assignment
operators (I think that's a requirement). If that's true then you can use
a look-ahead technique copying the current iterator until the next is
what you are looking for.

Implementation left as an excercise. (Is there a standard algorithm that
might fit well besides for_each()?)

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net