In the STL, there's an 'algorithms' package, that gives you a whole bunch of useful stuff: http://www.cplusplus.com/reference/algorithm/