在此期间,它不是很难自己进行copy_if()使用remove_copy_if():
#include <functional>
struct my_predicate : std::unary_function<my_arg_type, bool> {
bool operator()(my_arg_type const& x) const { ... }
};
// To perform "copy_if(x, y, z, my_predicate())", write:
remove_copy_if(x, y, z, std::not1(my_predicate()));
Run Code Online (Sandbox Code Playgroud)
使用not1()要求你的谓词类提供嵌套类型,argument_type识别参数的类型 - 如上所示,一个方便的方法是从中派生unary_function<T, U>,T参数类型在哪里.