16.1. Introduction

This chapter continues our discussion of the Standard Library’s containers, iterators and algorithms by focusing on algorithms that perform common data manipulations such as searching, sorting and comparing elements or entire containers. The Standard Library provides over 90 algorithms, many of which are new in C++11. The complete list can be found in Sections 25 and 26.7 of the C++ standard document and there are various online references where you can learn about each algorithm, such as en.cppreference.com/w/cpp/algorithm. Most of them use iterators to access container elements. As you’ll see, various algorithms can receive a function pointer (a pointer to a function’s code) as an argument. Such algorithms use the pointer to call the function—typically with one or two container elements as arguments. We’ll introduce function pointers in more detail in this chapter. Later in the chapter we’ll present the concept of a function object, which is similar to a function pointer but is implemented as an object of a class that has an overloaded function-call operator (operator()) so that the object can be used like a function name. Finally, we’ll introduce lambda expressions—C++11’s new shorthand mechanism for creating anonymous function objects (that is, function objects that do not have names).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.100.20