Are there any advantages of std::for_each over for loop? To me, std::for_each only seems to hinder the readability of code. Why do then some coding standards recommend its use?
Are there any advantages of std::for_each over for loop? To me, std::for_each only seems
Share
The nice thing with C++11 (previously called C++0x), is that this tiresome debate will be settled.
I mean, no one in their right mind, who wants to iterate over a whole collection, will still use this
Or this
when the range-based
forloop syntax is available:This kind of syntax has been available in Java and C# for some time now, and actually there are way more
foreachloops than classicalforloops in every recent Java or C# code I saw.