主题:bind2nd函数的疑惑
template<class T, class U>
class CFindMapValueBinary : public binary_function<T, U, bool>
{
public:
bool operator()(typename map<T, U>::value_type iter, U &value)
{
return iter.second == value;
}
};
int main()
{
binder2nd<CFindMapValueBinary<int, int> > it = bind2nd(CFindMapValueBinary<int, int>(),15);
find_if(intMap.begin(), intMap.end(), it);
return 0;
}
这么写好像不对,请问正确的写法是怎么样的?
class CFindMapValueBinary : public binary_function<T, U, bool>
{
public:
bool operator()(typename map<T, U>::value_type iter, U &value)
{
return iter.second == value;
}
};
int main()
{
binder2nd<CFindMapValueBinary<int, int> > it = bind2nd(CFindMapValueBinary<int, int>(),15);
find_if(intMap.begin(), intMap.end(), it);
return 0;
}
这么写好像不对,请问正确的写法是怎么样的?