Re: [Boost-users] The boost Tokenizer package: split into a vectorof vectors of tokens
Pavol Droba wrote:
On Sat, Dec 24, 2005 at 09:06:51AM +0200, Alex Vinokur wrote:
"Pavol Droba"
wrote in message news:20051223180408.GP15407@lenin.felcer.sk... Hi,
You might be able to do it using the string_algo find_iterator.
#include
using namespace std; using namespace boost;
...
[snip] typedef split_iteratorstring::iterator string_find_iterator; ------------------------------------------------------------------------------
string_find_iterator It=make_find_iterator(str1, token_finder(is_space()));
That line produces the following error message:
error: conversion from `boost::algorithm::find_iterator<__gnu_cxx::__normal_iterator
> >' to non-scalar type `boost::algorithm::split_iterator<__gnu_cxx::__normal_iterator > >' requested Sorry, I have fixed one error, but the other line was tied to it. the second line should be string_find_iterator It=make_split_iterator(str1, token_finder(is_space()));
Regards, Pavol
Thanks.
Here is what I compiled:
--------
#include<iostream>
#include
-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 On Fri, Dec 30, 2005 at 04:17:52PM +0200, Alex Vinokur wrote:
Here is what I compiled:
sorry for jumping in, i'm not really acquainted with the tokenizer package, but the following code just looks "wrong" in one tiny little detail :)
for(int i=0; i < maxi; i++) { for(int j=0; j < maxj; j++) { if(It != string_find_iterator()) cout << "(" << i << ", " << j << ") : " << (*It) << endl; else break; } } }
In this loop you forget to increment the iterator.. try *It++ , or if that doesn't compile, just write: if(It != string_find_iterator()) { cout << "(" << i << ", " << j << ") : " << (*It) << endl; ++It; } That's how I intuitively understand the concept of iterators :) Best regards, Zeljko. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDtVKiFtofFpCIfhMRA5DqAJ0beuAeAl1wN9PCrfwAt8u4RlnEuwCgiCSG nEfe+FeAz+mzao5/DdBxjY8= =3V1D -----END PGP SIGNATURE-----
if(It != string_find_iterator()) cout << "(" << i << ", " << j << ") : " << (*It) << endl;
Modify this line to (*It) ==> (*It++) if(It != string_find_iterator()) cout << "(" << i << ", " << j << ") : " << (*It++) << endl; And output would be $ ./a.exe (0, 0) : ab (0, 1) : cd (1, 0) : (1, 1) : (2, 0) : xy (2, 1) : z Thank you, NitiN ( NITIN DOT MOTGI AT GMAIL DOT COM )
participants (3)
-
Alex Vinokur
-
nitin motgi
-
zvrba@globalnet.hr