std::for_each vs. range-based for-loops

Jan Holesovsky kendy at collabora.com
Tue Aug 11 06:30:24 PDT 2015


Hi Daniel,

I've just seen you are doing some great work cleaning up the o3tl stuff,
and using lambdas instead - thanks for that!

I was wondering what would be the drawbacks of going even further, and
getting rid of the std::for_each for good, and use the range-based
for-loops instead?

Like:

-    std::for_each( maAllShapes.begin(),
-                   maAllShapes.end(),
-                   []( const LayerShapeMap::value_type& cp )
-                   { cp.first->clearAllViewLayers(); } );
+    for (auto& cp : maAllShapes)
+        cp.first->clearAllViewLayers();

is I think even more readable?  Would you be up for that? :-)

All the best,
Kendy



More information about the LibreOffice mailing list