14 May
2008
14 May
'08
3:55 p.m.
AMDG Dan Smithers wrote:
boost::sregex_iterator it(sm[1].str().begin(), sm[1].str().end(), handles);
str() returns a std::string by *value* Thus, the two iterators point into different string objects.
I get a segmentation fault if I run this - sometimes with a memory exhausted notice.
If I replace the iterator line
boost::sregex_iterator it(sm[1].str().begin(), sm[1].str().end(), handles);
with
const string& hs(sm[1].str()); boost::sregex_iterator it(hs.begin(), hs.end(), handles);
then everything seems to work.
What's going on here? Is there a simpler way of achieving this?
Now you only get one string object. In Christ, Steven Watanabe