他们是否将copy_if添加到c ++ 0x?

rlb*_*ond 7 c++ algorithm c++11

非常烦人,copy_if不是在C++中.有谁知道它是否会在C++ 0x中?

Bur*_*ard 7

由于C++ 0x尚未最终确定,因此您只能查看最新的草稿.


j_r*_*ker 5

在此期间,它不是很难自己进行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参数类型在哪里.