I noticed that you changed most instances of for loops to use the keyword
auto to determine type. This definitely helps to reduce line length and
improve the readability of the code, but I don't think auto can be used to
get a const_iterator. Taking one example from lo-regexp.cc
- regexp::match_data::const_iterator p = rx_lst.begin ();
+ auto p = rx_lst.begin ();
The method begin() is going to return a regular iterator. This will
certainly work, but then there won't be a compile time check if the code
attempts to modify rx_lst accidentally, which it shouldn't be doing. I
don't think you can solve it by using 'const auto p', because then the
iterator itself is fixed so p++ will fail if you try to advance. If this
were C++14 then we could call the method cbegin() which has a function
prototype that returns const_iterator so auto would correctly deduce the
right type. Stack Overflow doesn't recommend using auto in this scenario:
https://stackoverflow.com/questions/15233188/how-do-i-get-a-const-iterator-using-auto#15233309.
Although, if you're open to further code changes then it would be possible
to work on a const reference to the original.