Mastering Standard Library Algorithms

Marc Gregoire · 2021

This chapter looks at how Standard Library algorithms can be used in practice. The “magic” behind the algorithms is that they work on iterator intermediaries instead of on the containers themselves. All the Standard Library algorithms are implemented as function templates, where the template type parameters are usually iterator types. The iterators themselves are specified as arguments to the function. The chapter provides coding examples for a selection of Standard Library algorithms. The Standard Library provides a variety of modifying sequence algorithms that perform tasks such as copying elements from one range to another, removing elements, or reversing the order of elements in a range. The chapter shows the readers that combining these algorithms with lambda expressions allows them to write elegant and easy-to-understand code.

Read the paper · More papers on PaperTik