[cfe-dev] clang-modernize: Can't get Loop Transform to work for STL for loops
Matt Calabrese
rivorus at gmail.com
Fri Apr 3 14:12:44 PDT 2015
On Fri, Apr 3, 2015 at 10:54 AM, GerdH <gerd.hoeren at autodesk.com> wrote:
> 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?
Hmm, I don't have a direct answer for you, but the transformation there
does technically imply the loop changing from using const_iterator behind
the scenes to using iterator behind the scenes, so this might be
intentional. It depends on where the line is drawn regarding what is
considered to be only a minor change of behavior.
--
-Matt Calabrese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150403/e3a2adf4/attachment.html>
More information about the cfe-dev
mailing list