Вы должны написать bind_both
адаптер самостоятельно
it2 = std::find_if(v2.begin(), v2.end(), bind_both(std::equal_to<int>(), std::mem_fn_ref(&Class::getType), 4));
И у него будет комбинаторный взрыв возможностей
template <typename Binary, typename Left, typename Arg>
class bind_left_t : public std::unary_function<Arg, typename Binary::result_type> {
Binary b;
Left l;
typename Binary::second_argument_type r;
public:
bind_left_t(Binary b, Left l, typename Binary::second_argument_type r) : b(b), l(l), r(r) {}
typename Binary::result_type operator()( Arg & arg) const { return b(l(arg), r); }
typename Binary::result_type operator()(const Arg & arg) const { return b(l(arg), r); }
};
template <typename Binary, typename Right, typename Arg>
class bind_right_t : public std::unary_function<Arg, typename Binary::result_type> {
Binary b;
typename Binary::first_argument_type l;
Right r;
public:
bind_right_t(Binary b, typename Binary::first_argument_type l, Right r) : b(b), l(l), r(r) {}
typename Binary::result_type operator()( Arg & arg) const { return b(l, r(arg)); }
typename Binary::result_type operator()(const Arg & arg) const { return b(l, r(arg)); }
};
template <typename Binary, typename Left, typename Right, typename Arg1, typename Arg2>
class bind_both_t : public std::binary_function<Arg1, Arg2, typename Binary::result_type> {
Binary b;
Left l;
Right r;
public:
bind_both_t (Binary b, Left l, Right r) : b(b), l(l), r(r) {}
typename Binary::result_type operator()( Arg1 & arg1, Arg2 & arg2) const { return b(l(arg1), r(arg2)); }
typename Binary::result_type operator()(const Arg1 & arg1, Arg2 & arg2) const { return b(l(arg1), r(arg2)); }
typename Binary::result_type operator()( Arg1 & arg1, const Arg2 & arg2) const { return b(l(arg1), r(arg2)); }
typename Binary::result_type operator()(const Arg1 & arg1, const Arg2 & arg2) const { return b(l(arg1), r(arg2)); }
};
Дополнительные аргументы шаблона (Arg
, Arg1
и Arg2
) устранение неоднозначности между тремя формами при вызове bind_both
template <typename Binary, typename Left>
bind_left_t<Binary, Left, typename Left::argument_type> bind_both(Binary b, Left l, typename Binary::second_argument_type r)
{
return bind_left_t<Binary, Left, typename Left::argument_type>(b, l, r);
}
template <typename Binary, typename Right>
bind_right_t<Binary, Right, typename Right::argument_type> bind_both(Binary b, typename Binary::first_argument_type l, Right r)
{
return bind_right_t<Binary, Right, typename Right::argument_type>(b, l, r);
}
template <typename Binary, typename Left, typename Right>
bind_both_t<Binary, Left, Right, typename Left::argument_type, typename Right::argument_type> bind_both(Binary b, Left l, Right r)
{
return bind_both_t<Binary, Left, Right, typename Left::argument_type, typename Right::argument_type>(b, l, r);
}