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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.