不罗索,代码说话 using namespace std; template <class T> class A:public unary_function<T,bool> { public: A(T m):x(m){} bool operator()(T m)const { return m==x; } private: T x; }; template<class T> class B:public binary_function<T,T,bool> { public: // B():x(0){} bool operator()(const T& t1,const T& t2)const//这里const必不可少 { return t1<t2; } private: // T x; }; int main() { vector<int>col; INSERT(col,1,9);//自己定义的函数 //remove_if第三个参数需要一元谓词 remove_if(col.begin(),col.end(),A<int>(5)); //使用一元谓词,移除第一个等于5的 remove_if(col.begin(),col.end(),bind2nd(B<int>(),5));//使用二元谓词,移除多有小于5的 PRINT(col); return 0; }