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)

Notes

[1] Two different invocations of f may return different results, even if f is called with the same arguments both times. A Binary Function may refer to local state, perform I/O, and so on. The expression f(x,y) is permitted to change f's state.

See also

Function Object overview, Generator, Unary Function, Adaptable Binary Function

Adaptable Generator

Category: functors

Component type: concept

Description

An Adaptable Generator is a Generator with a nested typedef that defines its result type. [1] This nested typedef makes it possible to use function object adaptors.

Refinement of

Generator

Associated types
Result type F::result_type The type returned when the Generator is called
Notation

F A type that is a model of Adaptable Generator

Valid expressions

None, except for those defined by Generator

Models

The STL does not include any types that are models of Adaptable Generator. An example of a user-defined Adaptable Generator is as follows.

struct counter {

 typedef int result_type;

 counter() : n(0) {}

 result_type operator()() { return n++; }

 result_type n;

};

Notes

[1] Note the implication of this: a function pointer T (*f)() is a Generator, but not an Adaptable Generator: the expression f::result_type is nonsensical.

See also

Generator, Adaptable Unary Function, Adaptable Binary Function

Adaptable Unary Function

Category: functors

Component type: concept

Description

An Adaptable Unary Function is a Unary Function with nested typedefs that define its argument type and result type. [1] [2] These nested typedef make it possible to use function object adaptors.

Refinement of

Unary Function

Associated types
Argument type F::argument_type The type of F's argument
Result type F::result_type
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату