Re: [Boost-users] Extracting items from a string
29 Jun
2010
29 Jun
'10
4:10 p.m.
AMDG Sean Farrow wrote:
I have a string of the following format:
11, 0, 1461, 400
I need to be able to extract any element of the string at any point, so for example, the 1, would return 11, or the second world return 0. What is the best way of extracting any individual element, without using any temporary variables.
IF I use boost.tokenizer, can I access any element individually, without using iterators? Or is there a better way of dealing with this sort of string.
If you can't parse the string into a more suitable data structure, then you can't avoid searching from the beginning of the string on each access. Probably the easiest way is std::string element = *boost::next(make_token_iterator(...), n); In Christ, Steven Watanabe
5248
Age (days ago)
5248
Last active (days ago)
0 comments
1 participants
participants (1)
-
Steven Watanabe