逻辑仿函数-非
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
class Print
{
public:
void operator()(bool b)
{
cout << b << endl;
}
};
int main()
{
vector<bool> v;
v.push_back(true);
v.push_back(false);
v.push_back(true);
vector<bool> v2;
v2.resize(v.size());
transform(v.begin(), v.end(), v2.begin(), logical_not<bool>());
for_each(v2.begin(), v2.end(), Print());
return 0;
}
$ ./a.out
0
1
0