std::string line;
This throws std::runtime_error what(): Memory exhausted:
regex_it = boost::sregex_iterator(line.begin(), line.end(), re);
This works fine:
regex_it = boost::make_regex_iterator(line, re);
Does anyone know what is causing the difference in performance? The boost::regex lib is compiled on Linux in default non-recursive mode.
EDIT:
Also tried
regex_it = boost::cregex_iterator(line.data(), line.data()+line.size(), re);
same problem.
Try working with a
regex_iterator<char const*>rather than aregex_iterator<std::string::const_iterator>. (Also, the way you’re callingmake_regex_iteratoris unnecessarily verbose by a large measure.)Assuming
lineis astd::string, try this:or this: