Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSVC 10 range based for loop

Currently in a large c++ project we are working on we have a bunch of the new style for loops like the following:

for (auto& value : values)

Up till now we have been compiling exclusively with gcc 4.6. Recently some of the codebase is being ported to windows and some of the developers want to compile in msvc++ 10 but it seems as though the new for loop syntax is not fully supported yet.

It would be highly desirable to not have to re-write all the places where this syntax occurs.

What is the best way to work around this problem?

Update: It looks as though this issue is resolved in MSVC11.

like image 262
shuttle87 Avatar asked Sep 06 '26 04:09

shuttle87


1 Answers

You could use Boost.Foreach:

//Using Xeo's example:
BOOST_FOREACH (auto& e, values) {
    std::cout << e << " ";
}
like image 127
Mankarse Avatar answered Sep 07 '26 18:09

Mankarse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!