功能:
- 实现逻辑运算
#include<iostream> #include<vector> #include<functional> #include<algorithm> using namespace std; //逻辑仿函数 //逻辑非 logical_not void test1() { vector<bool> v; v.push_back(true); v.push_back(true); v.push_back(true); v.push_back(false); v.push_back(true); for (vector<bool>::iterator it = v.begin(); it != v.end(); it++) { cout << *it << " "; } cout << endl; //利用逻辑非 ,将容器v搬运到容器v2中, 并执行取反操作 vector<bool>v2; v2.resize(v.size()); transform(v.begin(), v.end(), v2.begin(), logical_not<bool>()); for (vector<bool>::iterator it = v2.begin(); it != v2.end(); it++) { cout << *it << " "; } cout << endl; } int main() { test1(); return 0; }
标签:begin,逻辑,函数,back,v2,push,include,true From: https://www.cnblogs.com/ggbond00/p/17201059.html