AdaptableBinaryFunction::second_argument_type
result_type Adaptable Unary Function The type of the result: AdaptableBinaryFunction::result_type
result_type operator()(const argument_type& x) const Adaptable Unary Function Function call. Returns F(c, x), where F and c are the arguments with which this binder1st was constructed.
binder1st(const AdaptableBinaryFunction& F, AdaptableBinaryFunction::first_argument_type c) binder1st See below
template <class AdaptableBinaryFunction, class T> binder1st<AdaptableBinaryFunction> bind1st(const AdaptableBinaryFunction& F, const T& c); binder1st See below
New members

These members are not defined in the Adaptable Unary Function requirements, but are specific to binder1st.

Member Description
binder1st(const AdaptableBinaryFunction& F, AdaptableBinaryFunction::first_argument_type c) The constructor. Creates a binder1st such that calling it with the argument x (where x is of type AdaptableBinaryFunction::second_argument_type ) corresponds to the call F(c, x).
template <class AdaptableBinaryFunction, class T> binder1st<AdaptableBinaryFunction> bind1st(const AdaptableBinaryFunction& F, const T& c); If F is an object of type AdaptableBinaryFunction, then bind1st(F, c) is equivalent to binder1st<AdaptableBinaryFunction>(F, c), but is more convenient. The type T must be convertible to AdaptableBinaryFunction::first_argument_type. This is a global function, not a member function.
Notes

[1] Intuitively, you can think of this operation as 'binding' the first argument of a binary function to a constant, thus yielding a unary function. This is a special case of a closure.

See also

The function object overview, binder2nd, Adaptable Unary Function, Adaptable Binary Function

binder2nd<AdaptableBinaryFunction>

Categories: functors, adaptors

Component type: type

Description

Binder2nd is a function object adaptor: it is used to transform an adaptable binary function into an adaptable unary function. Specifically, if f is an object of class binder2nd<AdaptableBinaryFunction>, then f(x) returns F(x, c), where F is an object of class AdaptableBinaryFunction and where c is a constant. Both F and c are passed as arguments to binder2nd's constructor. [1]

The easiest way to create a binder2nd is not to call the constructor explicitly, but instead to use the helper function bind2nd.

Example

Finds the first positive number in a list.

list<int> L;

list<int>::iterator first_positive = find_if(L.begin(), L.end(), bind2nd(greater<int>(), 0));

assert(first_positive == L.end() || *first_positive > 0);

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.

Template parameters
Parameter Description
AdaptableBinaryFunction The type of the binary function whose second argument is being bound to a constant.
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

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

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