question about using bind2nd to convert a binary predicate to unary predicate
Posted on 2003-10-29
In STL, "bind2nd" is used to convert a binary prediate to unary predicate. I try to declare a unary predicate by bind2nd, but it does not work.
Please tell me the reason.
using namespace std;
typedef vector<int>::iterator iterator;
// this part work well
iterator it1 = find_if(v.begin(), v.end(), bind2nd(equal_to<int>(), 3));
// however, the following doesn't work
unary_function<int,bool> p = bind2nd(equal_to<int>(), 3);
iterator it2 = find_if(v.begin(), v.end(), p);//when compile: error C2064: term does not evaluate to a function