Boost::tokenizer and reverse iterators
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I
have, I've tried hooking it to a reverse iterator.
This act produced a run-time error.
This is the code:
const string test = "One:Two:Three:Four";
typedef char_separator<char> Sep;
typedef tokenizer
perhaps you should try rbegin() and rend() like you're supposed to w/ reverse_iterators At Sunday 2004-05-30 04:56, you wrote:
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I have, I've tried hooking it to a reverse iterator. This act produced a run-time error.
This is the code: const string test = "One:Two:Three:Four"; typedef char_separator<char> Sep; typedef tokenizer
Tok; Sep sep(":"); Tok t(test,sep); for (Tok::iterator iter=t.end();iter!=t.begin();++iter) cout << *iter << endl; Executing this produces continous output of "garbage".
Switching the ".end()" and ".begin()" references in the for loop doesn't fix this problem. Switching from "const_reverse_iterator" to "const_iterator" produces the following output: One Two Three Four
Is there a way to use a reverse iterator with boost:tokenizer? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"
I've also tried rbegin/rend. However, the boost::tokenizer doesn't provide these methods, while it does provide begin/end. Victor A. Wagner Jr. wrote:
perhaps you should try rbegin() and rend() like you're supposed to w/ reverse_iterators At Sunday 2004-05-30 04:56, you wrote:
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I have, I've tried hooking it to a reverse iterator. This act produced a run-time error.
This is the code: const string test = "One:Two:Three:Four"; typedef char_separator<char> Sep; typedef tokenizer
Tok; Sep sep(":"); Tok t(test,sep); for (Tok::iterator iter=t.end();iter!=t.begin();++iter) cout << *iter << endl; Executing this produces continous output of "garbage".
Switching the ".end()" and ".begin()" references in the for loop doesn't fix this problem. Switching from "const_reverse_iterator" to "const_iterator" produces the following output: One Two Three Four
Is there a way to use a reverse iterator with boost:tokenizer? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law" _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Perhaps it doesn't provide them because reverse_iterator won't work. At Sunday 2004-05-30 07:40, you wrote:
I've also tried rbegin/rend. However, the boost::tokenizer doesn't provide these methods, while it does provide begin/end.
Victor A. Wagner Jr. wrote:
perhaps you should try rbegin() and rend() like you're supposed to w/ reverse_iterators At Sunday 2004-05-30 04:56, you wrote:
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I have, I've tried hooking it to a reverse iterator. This act produced a run-time error.
This is the code: const string test = "One:Two:Three:Four"; typedef char_separator<char> Sep; typedef tokenizer
Tok; Sep sep(":"); Tok t(test,sep); for (Tok::iterator iter=t.end();iter!=t.begin();++iter) cout << *iter << endl; Executing this produces continous output of "garbage".
Switching the ".end()" and ".begin()" references in the for loop doesn't fix this problem. Switching from "const_reverse_iterator" to "const_iterator" produces the following output: One Two Three Four
Is there a way to use a reverse iterator with boost:tokenizer? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law" _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"
"Victor A. Wagner Jr."
Thanks for this. However, I've figured out that "adopting" a string's reverse iterator isn't the same as having one. I wanted the tokens to be reversed, not the string.... Victor A. Wagner Jr. wrote:
perhaps you should try rbegin() and rend() like you're supposed to w/ reverse_iterators At Sunday 2004-05-30 04:56, you wrote:
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I have, I've tried hooking it to a reverse iterator. This act produced a run-time error.
This is the code: const string test = "One:Two:Three:Four"; typedef char_separator<char> Sep; typedef tokenizer
Tok; Sep sep(":"); Tok t(test,sep); for (Tok::iterator iter=t.end();iter!=t.begin();++iter) cout << *iter << endl; Executing this produces continous output of "garbage".
Switching the ".end()" and ".begin()" references in the for loop doesn't fix this problem. Switching from "const_reverse_iterator" to "const_iterator" produces the following output: One Two Three Four
Is there a way to use a reverse iterator with boost:tokenizer? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law" _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Probably not. There are a couple of things here: 1. The base iterator (string::const_reverse_iterator) scans the string in reverse. Even if you got the tokens in the order you wanted, their content would be reversed. 2. The above caveat also applies when parsing multi-character delimiters. 3. The documentation (http://www.boost.org/libs/tokenizer/tokenizer.htm ) specifically says: "Note: the category of iterator will be at most ForwardIterator" You can probably do what you want if you first reverse the data string (and delimiters), then tokenize, and finally reverse the resulting strings. Eventually a reverse_iterator facade/adaptor over a bidirectional tokenizer would do the job; but that's another story. --rich On Sunday, May 30, 2004, at 07:56 AM, Jeff Holle wrote:
I'm using boost v1_31_0 and gcc v3.3.2
In experimenting with boost::tokenizer to meet a requirement that I have, I've tried hooking it to a reverse iterator. This act produced a run-time error.
This is the code: const string test = "One:Two:Three:Four"; typedef char_separator<char> Sep; typedef tokenizer
Tok; Sep sep(":"); Tok t(test,sep); for (Tok::iterator iter=t.end();iter!=t.begin();++iter) cout << *iter << endl; Executing this produces continous output of "garbage".
Switching the ".end()" and ".begin()" references in the for loop doesn't fix this problem. Switching from "const_reverse_iterator" to "const_iterator" produces the following output: One Two Three Four
Is there a way to use a reverse iterator with boost:tokenizer? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Jeff Holle
-
Rich Johnson
-
Thorsten Ottosen
-
Victor A. Wagner Jr.