Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Convert for loops to range-based for loops
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jay.carlton
Ketchup Master

USA
65 Posts

Posted - Oct 31 2013 :  10:48:32 PM  Show Profile  Reply with Quote
Hi,

So one of the very nice things in C++11 is range-based for loops.
http://www.cprogramming.com/c 11/c 11-ranged-for-loop.html

Since it's so much clearer without being less expressive than the old-fashioned kind, it would be really nice to have a tool that could find eligible for loops and replace the for statement with an equivalent range statement.

So instead of

for (auto itElem = vec.begin(); itElem != vec.end(); ++itElem) {}


we would have
for (auto& elem : vec) {}


I guess the main trick is distinguishing the reference case from the copy case for the iterator, and making sure you don't change the semantics of any of the loops.

Thanks,
Jay

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Nov 01 2013 :  10:27:31 PM  Show Profile  Reply with Quote
This is an interesting idea, and this new syntax is a lot more compact and clean. I have put in a feature request to see what our developers make of it:

case=78175

I am not sure about updating all loops in your solution, but a refactoring to update specific loops, on a loop by loop basis, makes sense.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000