• less_equal
• logical_and
• logical_or
• logical_not
• subtractive_rng
• identity
• project1st
• project2nd
• select1st
• select2nd
• unary_function
• binary_function
• unary_compose
• binary_compose
• unary_negate
• binary_negate
• binder1st
• binder2nd
• pointer_to_unary_function
• pointer_to_binary_function
Functions
• compose1
• compose2
• not1
• not2
• bind1st
• bind2nd
• ptr_fun
Notes
[1] The reason for the name "adaptable function object" is that adaptable function objects may be used by function object adaptors.
[2] The unary_function and binary_function bases are similar to the input_iterator , output_iterator , forward_iterator , bidirectional_iterator , and random_access_iterator bases: they are completely empty, and serve only to provide type information.
[3] This is an example of how to use function objects; it is not the recommended way of calculating the sum of elements in a vector. The accumulate algorithm is a better way of calculating a sum.
Category: functors
Component type: concept
Description
A Generator is a kind of function object: an object that is called as if it were an ordinary C++ function. A Generator is called with no arguments.
Refinement of
Assignable
Associated types
Result type |
The type returned when the Generator is called |
Notation
F
A type that is a model of Generator
Result
The result type of F
f
Object of type F
Definitions
The range of a Generator is the set of all possible value that it may return.
Valid expressions
Name |
Expression |
Return type |
Function call |
f() |
Result |
Expression semantics
Name |
Expression |
Semantics |
Postcondition |
Function call |
f() |
Returns some value of type Result [1] |
The return value is in f 's range. |
Models
• Result (*)()
Notes
[1] Two different invocations of f may return different results: a Generator may refer to local state, perform I/O, and so on. The expression f() is permitted to change f 's state; f might, for example, represent a pseudo-random number generator.
See also
Function Object overview, Unary Function, Binary Function, Adaptable Generator
Category: functors
Component type: concept
Description
A Unary Function is a kind of function object: an object that is called as if it were an ordinary C++ function. A Unary Function is called with a single argument.
Refinement of
Assignable
Associated types
Argument type |
The type of the Unary Function's argument. |
Result type |
The type returned when the Unary Function is called |
Notation
F
A type that is a model of Unary Function
X
The argument type of F
Result
The result type of F
f
Object of type F
x
Object of type X
Definitions
The domain of a Unary Function is the set of all permissible values for its argument.
The range of a Unary Function is the set of all possible values that it may return.
Valid expressions
Name |
Expression |
Return type |
Function call |
f(x) |
Result |
Expression semantics
Name |
Expression |
Precondition |
Semantics |
Postcondition |
Function call |
f(x) |
x is in f 's domain |
Calls f with x as an argument, and returns a value of type Result [1] |
The return value is in f 's range |
Models
• Result (*)(X)
Notes
[1] Two different invocations of f may return different results, even if f is called with the same arguments both times. A Unary Function may refer to local state, perform I/O, and so on. The expression f(x) is permitted to change f 's state.
See also
Function Object overview, Generator, Binary Function Adaptable Unary Function
Category: functors
Component type: concept
Description
A Binary Function is a kind of function object: an object that is called as if it were an ordinary C++ function. A Binary Function is called with two arguments.
Refinement of
Assignable
Associated types
First argument type |
The type of the Binary Function's first argument. |
Second argument type |
The type of the Binary Function's second argument. |
Result type |
The type returned when the Binary Function is called |
Notation
F
A type that is a model of BinaryFunction
X
The first argument type of F
Y
The second argument type of F
Result
The result type of F
f
Object of type F
x
Object of type X
y
Object of type Y
Definitions
The domain of a Binary Function is the set of all ordered pairs (x, y) that are permissible values for its arguments.
The range of a Binary Function is the set of all possible value that it may return.
Valid expressions
Name |
Expression |
Return type |
Function call |
f(x,y) |
Result |
Expression semantics
Name |
Expression |
Precondition |
Semantics |
Postcondition |
Function call |
f(x,y) |
The ordered pair (x,y) is in f 's domain |
Calls f with x and y as arguments, and returns a value of type Result [1] |
The return value is in f 's range |
Models
• Result (*)(X,Y)
Читать дальше