Raw loops vs STL algorithms

A new post on the Meeting C++ blog, this time on <algorithm>

Raw loops vs. STL algorithms

by Jens Weller

From the article:

Since last week I am working on my CMS for static HTML pages again, and so the series about Building applications with Qt and boost continues. Today its about using STL algorithms, or how Sean Parent once said "no raw loops!". Now, I am not Sean Parent, and not event the implementers of the STL are perfect. Most code which I write is application code, which then powers Meeting C++. Also, I don't know all STL algorithms, and some times its just to tempting to write a little loop instead of searching the STL for the specific algorithm. Yesterday I had such a case.

Add a Comment

Comments are closed.

Comments (2)

1 0

Bjarne Stroustrup said on Feb 6, 2016 03:49 PM:

I wonder what kind of performance the different kinds of loops deliver? Last I checked, there were no difference among C-style for loops, range-for loops, and for_each with the action as a lambda argument.
0 0

Greg Marr said on Feb 6, 2016 04:03 PM:

The ability to fix the last issue, with the begin and size from Qt not being able to be replaced by for_each, should hopefully be coming with Eric Niebler's range work, which is adding counted iterators.