The binders binder1st, bind1st, binder2nd, and bind2nd are deprecated. [ Note: The function template bind ([func.bind.bind]) provides a better solution. — end note ]
template <class Fn>
class binder1st
: public unary_function<typename Fn::second_argument_type,
typename Fn::result_type> {
protected:
Fn op;
typename Fn::first_argument_type value;
public:
binder1st(const Fn& x,
const typename Fn::first_argument_type& y);
typename Fn::result_type
operator()(const typename Fn::second_argument_type& x) const;
typename Fn::result_type
operator()(typename Fn::second_argument_type& x) const;
};
The constructor initializes op with x and value with y.
operator() returns op(value,x).
template <class Fn, class T>
binder1st<Fn> bind1st(const Fn& fn, const T& x);
Returns: binder1st<Fn>(fn, typename Fn::first_argument_type(x)).
template <class Fn>
class binder2nd
: public unary_function<typename Fn::first_argument_type,
typename Fn::result_type> {
protected:
Fn op;
typename Fn::second_argument_type value;
public:
binder2nd(const Fn& x,
const typename Fn::second_argument_type& y);
typename Fn::result_type
operator()(const typename Fn::first_argument_type& x) const;
typename Fn::result_type
operator()(typename Fn::first_argument_type& x) const;
};
The constructor initializes op with x and value with y.
operator() returns op(x,value).
template <class Fn, class T>
binder2nd<Fn> bind2nd(const Fn& op, const T& x);
Returns: binder2nd<Fn>(op, typename Fn::second_argument_type(x)).
[ Example:
find_if(v.begin(), v.end(), bind2nd(greater<int>(), 5));
finds the first integer in vector v greater than 5;
find_if(v.begin(), v.end(), bind1st(greater<int>(), 5));
finds the first integer in v less than 5. — end example ]