Implement operator[] for Tokenizer
I constantly find myself creating this structure:
tokenizer tok(str, sep);
vector<string> s;
for(tokenizer::iterator iter=tok.begin();
iter!=tok.end(); ++iter) {
s.push_back(*iter);
}
Why not just:
tok[0];
to retrieve the first token?
(Darel Finkbeiner <darel.finkbeiner@sbcglobal.net>)
Change History
(4)
Description: |
modified (diff)
|
Owner: |
changed from John Maddock to jsiek
|
Severity: |
→ Problem
|
Status: |
assigned → new
|
Component: |
regex → tokenizer
|
Resolution: |
None → wontfix
|
Status: |
new → closed
|
The correct solution to this is
tokenizer cannot support random access efficiently because it is lazy and only has forward iterators.