Categories: functors, adaptors | Component type: type |
The easiest way to create a binder2nd is not to call the constructor explicitly, but instead to use the helper function bind2nd.
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);
Parameter | Description | Default |
---|---|---|
AdaptableBinaryFunction | The type of the binary function whose second argument is being bound to a constant. |
unary_function<AdaptableBinaryFunction::first_argument_type, AdaptableBinaryFunction::result_type>
Member | Where defined | Description |
---|---|---|
argument_type | Adaptable Unary Function | The type of the function object's argument, which is AdaptableBinaryFunction::first_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(x, c), where F and c are the arguments with which this binder1st was constructed. |
binder2nd(const AdaptableBinaryFunction& F, AdaptableBinaryFunction::second_argument_type c) |
binder2nd | See below |
template <class AdaptableBinaryFunction, class T> binder2nd<AdaptableBinaryFunction> bind2nd(const AdaptableBinaryFunction& F, const T& c); |
binder2nd | See below |
Member | Description |
---|---|
binder2nd(const AdaptableBinaryFunction& F, AdaptableBinaryFunction::second_argument_type c) |
The constructor. Creates a binder2nd such that calling it with the argument x (where x is of type AdaptableBinaryFunction::first_argument_type) corresponds to the call F(x, c). |
template <class AdaptableBinaryFunction, class T> binder2nd<AdaptableBinaryFunction> bind2nd(const AdaptableBinaryFunction& F, const T& c); |
If F is an object of type AdaptableBinaryFunction, then bind2nd(F, c) is equivalent to binder2nd<AdaptableBinaryFunction>(F, c), but is more convenient. The type T must be convertible to AdaptableBinaryFunction::second_argument_type. This is a global function, not a member function. |
[1] Intuitively, you can think of this operation as "binding" the second argument of a binary function to a constant, thus yielding a unary function. This is a special case of a closure.
Contact Us | Site Map | Trademarks | Privacy | Using this site means you accept its Terms of Use |
Copyright © 2009 - 2014 Silicon Graphics International. All rights reserved. |