
20 Mar
2004
20 Mar
'04
11:58 a.m.
int main() { string s; getline(cin, s); sregex_token_iterator i(s.begin(), s.end(), regex("\\s+"), -1); // error here: temporary passed to constructor!
However, the first example given in http://boost.org/libs/regex/doc/regex_token_iterator.html works fine, so I don't know what's going on.
You're passing a temporary regex object to the iterator, the regex object must exist for the lifetime of the iterator (before you suggest it.... in a future regex release, I want to make regex copying O(1) and store a copy rather than a reference here). I made this requirement clear in the regex_iterator docs, but apparently not in the regex_token_iterator docs, so I'll get them updated ASAP, Thanks, John.