Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2004-03-20 06:58:57


> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk