24 Jun
2002
24 Jun
'02
3:32 p.m.
"the_d.geo"
[...] stringbuf line; ... string tmp = line.str(); if (regex_match(tmp, matchInfo, linerx)) { string name = regex_format(matchInfo, "$1"); } [...]
John has already eyplained, why it won't work with a temporary. In addition to that, you can avoid the copying of the string, too, by taking advantage of the fact that temporaries bound to constant references will won't be destroyed for the reference's lifetime: const string& tmp = line.str(); // note the const ref if (regex_match(tmp, matchInfo, linerx)) { string name = regex_format(matchInfo, "$1"); } Schobi