一元函数对象:函数参数1个;
二元函数对象:函数参数2个;
一元谓词 函数参数1个,函数返回值是bool类型,可以作为一个判断式
谓词可以使一个仿函数,也可以是一个回调函数。
二元谓词 函数参数2个,函数返回值是bool类型
具体看如下代码,
template<typename T>
class IsDiv
{
public:
IsDiv(const T& divisor)
{
this->divisor = divisor;
}
bool operator()(T& t)
{
return (t % divisor == 0);
}
protected:
private:
T divisor;
};
void main03()
{
vector<int> v2;
for (int i = 10; i < 33; i++)
{
v2.push_back(i);
}
int a = 4;
IsDiv<int> myDiv(a);
//find_if(v2.begin(), v2.end(), myDiv );
/*
template<class _InIt,
class _Pr> inline
_InIt find_if(_InIt _First, _InIt