Why there is no std::copy_if algorithm?(为什么没有 std::copy_if 算法?)
问题描述
在 C++ 中没有 std::copy_if 算法有什么具体原因吗?我知道我可以使用 std::remove_copy_if 来实现所需的行为.我认为它是在 C++0x 中出现的,但是一个简单的 copy_if 需要一个范围、一个输出迭代器和一个函子会很好.它只是简单地错过了还是背后有其他原因?
Is there any specific reason for not having std::copy_if algorithm in C++ ? I know I can use std::remove_copy_if to achieve the required behavior. I think it is coming in C++0x, but a simple copy_if which takes a range, a output iterator and a functor would have been nice. Was it just simply missed out or is there some other reason behind it?
推荐答案
根据 Stroustrup 的C++ 编程语言",这只是一个疏忽.
According to Stroustrup's "The C++ Programming Language" it was just an over-sight.
(作为引文,在 boost 邮件列表中回答了同样的问题:copy_if)
(as a citation, the same question answered in boost mail-lists: copy_if)
这篇关于为什么没有 std::copy_if 算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么没有 std::copy_if 算法?
基础教程推荐
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
