Preferring STL algorithms from algorithm and numeric -- makramkd

(Related note: If you haven't yet watched and grokked Sean Parent's wonderful C++ Seasoning talk from last fall's GoingNative conference, do yourself a favor and watch it. You will find it eye-opening. If you have already watched it, you might still find it worth a re-watch to fully absorb.)

Here's a nice case study of why not to roll your own algorithms, when C++ comes with a treasure chest full of pre-written, pre-debugged, and pre-optimized (in a good way) standard algorithms in the box:

Preferring STL algorithms from algorithm and numeric

by makramkd

From the article:

This post isn’t meant to be a documentation of the algorithm and numeric headers: you can find those readily at cppreference. In this post I’m going to try to convince people that write very similar algorithms to those in the standard library to not use these algorithms in production code, and to prefer ones from the STL.

Let’s get the show on the road. I’m going to start with the most simple one, because I just want to get my point across.

Add a Comment

Comments are closed.

Comments (1)

0 0

NoSenseEtAl said on Apr 25, 2014 07:23 PM:

what irritates me that map, set dont have remove_if and generic remove_if doesnt work on them? any known workaround beside manual looping?
http://stackoverflow.com/a/800984/700825
any plans to fix it in ISO?