O'Reilly logo

Beginning C++ Programming by Richard Grimes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Function objects

A function object, or functor, is a custom type that implements the function call operator: (operator()). This means that a function operator can be called in a way that looks like it is a function. Since we haven't covered classes yet, in this section we will just explore the function objects types that are provided by the Standard Library and how to use them.

The <functional> header file contains various types that can be used as function objects. The following table lists these:

Purpose Types
Arithmetic divides, minus, modulus, multiplies, negate, plus
Bitwise bit_and, bit_not, bit_or, bit_xor
Comparison equal_to, greater, greater_equal, less, less_equals, not_equal_to
Logical logical_and, logical_not, logical_or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required