逻辑仿函数 逻辑非
发布日期:2022-03-04 12:48:34 浏览次数:24 分类:技术文章

本文共 671 字,大约阅读时间需要 2 分钟。

黑马242

#include
#include
#include
#include
#include
#include
using namespace std;
//逻辑非 logical_not
class myCompare
{
public:
bool operator()(int v1, int v2)
{
return v1 > v2;
}
};
void test01()
{
vector < bool > v;
v.push_back(true);
v.push_back(true);
v.push_back(false);
v.push_back(true);
v.push_back(false);
for (vector::iterator it =v.begin(); it != v.end(); it++)
{
cout << *it << " ";
}
cout << endl;

//利用逻辑非 将容器v搬运到容器v2中,并执行取反操作vector
v2;v2.resize(v.size());transform(v.begin(),v.end(),v2.begin(),logical_not
());for (vector
::iterator it = v2.begin(); it != v2.end(); it++){ cout << *it << " ";}

}

int main()

{
test01();
}

转载地址:https://blog.csdn.net/qq_43752920/article/details/120536233 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:排序算法-洗牌算法
下一篇:常用遍历算法for_each

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月23日 04时16分41秒