[cfe-dev] clang-modernize: Can't get Loop Transform to work for STL for loops
GerdH
gerd.hoeren at autodesk.com
Fri Apr 3 10:54:46 PDT 2015
I’ve run clang-modernize over several hundred thousand lines of legacy C++.
It does a good job of converting non-const-iterator loops, like
int i;
std::vector<int> my_container;
for (std::vector<int>::iterator iter = my_container.begin(); iter !=
my_container.end(); ++iter) {
i = *iter;
}
To
int i;
std::vector<int> my_container;
for (auto & elem : my_container) {
i = elem;
}
But, the same loop with a const_iterator doesn’t get converted. I’d expect:
for (std::vector<int>::const_iterator iter = my_container.begin(); iter
!= my_container.end(); ++iter) {
i = *iter;
}
To transform into:
for (const auto & elem : my_container) {
i = elem;
}
Is this a reasonable transformation?
Is it a bug or enhancement request?
____
Gerd
--
View this message in context: http://clang-developers.42468.n3.nabble.com/clang-modernize-Can-t-get-Loop-Transform-to-work-for-STL-for-loops-tp4044770p4044824.html
Sent from the Clang Developers mailing list archive at Nabble.com.
More information about the cfe-dev
mailing list