Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace for-iterator loops with for-each loops and algorithm functions under libs/ #949

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

aledomu
Copy link
Contributor

@aledomu aledomu commented Nov 19, 2024

No description provided.

Copy link
Contributor

@pauldavisthefirst pauldavisthefirst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be very dangerous to do automatically. Perhaps the sed replacements handle it, but there are container-specific cases where erase invalidates the iterator and the code structure doesn't allow for i = container.erase()

Also, I don't see the point in using a type in the for loop if these changes are made. Why not just for (auto & i : container) { ... } ?

@x42
Copy link
Member

x42 commented Nov 19, 2024

or better yet with explicit const for (auto const& i : container) { ... }

@x42
Copy link
Member

x42 commented Nov 19, 2024

for loops are one of the only good uses for auto. IMHO

Comment on lines +667 to +668
for (const std::pair<const string, string>& m : cd_info) {
node->add_child_nocopy(cd_info_node(m.first, m.second));
Copy link

@keryell keryell Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual modern way is

Suggested change
for (const std::pair<const string, string>& m : cd_info) {
node->add_child_nocopy(cd_info_node(m.first, m.second));
for (auto&& [some_stuff, another_thing] : cd_info) {
node->add_child_nocopy(cd_info_node(some_stuff, another_thing));

picking the right names obviously.

…op in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4(?:\.|->)end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<\1* const&,\2>& \3 : \4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4(?:\.|->)end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<const \1,\2>& \3 : \4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<\1* const&,\2>& \3 : *\4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4(?:\.|->)end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<const \1,\2>& \3 : *\4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<\1* const&,\2>& \3 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (std::pair<const \1,\2>& \3 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
…ach loop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<\1* const&,\2>& \3 : \4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<const \1,\2>& \3 : \4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<\1* const&,\2>& \3 : *\4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*\4->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<const \1,\2>& \3 : *\4) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]\*[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<\1* const&,\2>& \3 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?map<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n],[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\3[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\3|\3\+\+)\)[ \t\n]*\{ -> for (const std::pair<const \1,\2>& \3 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
… loop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
…r-each loop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?vector<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : this) {

Any dereferencing of the loop internal variable has to be removed manually.
…op in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
…ach loop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?set<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
…oop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1& \2 : *this) {

Any dereferencing of the loop internal variable has to be removed manually.
…each loop in libs/

Regex substitutions have to be run in the following order:
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)\.begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3\.end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : \3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*(.*)->begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*\3->end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : *\3) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*\*[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (\1* const& \2 : *this) {
for[ \t\n]*\([ \t\n]*(?:typename )?[ \t\n]*(?:std::)?list<[ \t\n]*(?:typename )?[ \t\n]*(?:struct )?[ \t\n]*(.*)[ \t\n]*>::const_iterator[ \t\n]+(.*)[ \t\n]*=[ \t\n]*begin[ \t\n]*\(\);[ \t\n]*\2[ \t\n]*(?:<|!=)[ \t\n]*end[ \t\n]*\(\);[ \t\n]*(?:\+\+\2|\2\+\+)\)[ \t\n]*\{ -> for (const \1& \2 : this) {

Any dereferencing of the loop internal variable has to be removed manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants