例1
struct startingWith
{
char c;
startWith(char a)
{
c=a;
}
bool operator () (string s)
{
if(s.empty())
return false;
else
return(s[0]==c);
}
};
result=find_if(v.begin(),v.end(),startingWith('e'));
例2
class BetweenCls
{
public:
BetweenCls(int ival1,int ival2):lowerBound(ival1),upperBound(ival2){}
bool operator() (const int&ival)
{
return(ival>lowerBoud && ival<upperBound);
}
private:
int lowerBound,upperBound;
};