Annex B

C++ Function Objects and Lambda Expressions

In C++, a callable object is an object or expression to which the call operator () can be applied. Functions and—as we will see below—function pointers are callable objects inherited from C. C++ adds two other callable types of objects, function objects and lambda expressions, which are the subject of this annex.

B.1 Function Objects

Function objects are heavily used by STL algorithms to incorporate user-defined behavior in the library. They generalize the concept of function pointers, enabling some programming capabilities that are not easily implemented with function pointers alone. We have seen that function objects are used by TBB in the STL-like algorithms implementing parallel patterns, ...

Get Shared Memory Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.