#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <functional>
using namespace std;
void test()
{
negate<int> n;
cout << n(10) << endl; // 输出 -10
}
void test2()
{
plus<int> p;
cout << p(10, 20) << endl;
}
class MyCompare
{
public:
bool operator()(int a, int b)const
{
return a > b;
}
};
void test3()
{
vector<int> v;
v.push_back(10);
v.push_back(30);
v.push_back(20);
for(vector<int>::iterator i = v.begin(); i != v.end(); i++)
{
cout << *i << " ";
}
cout<< endl;
//sort(v.begin(), v.end() , MyCompare());
sort(v.begin(), v.end(), greater<int>());
for(vector<int>::iterator i = v.begin(); i != v.end(); i++)
{
cout << *i << " ";
}
}
void test4()
{
vector<bool> v;
v.push_back(true);
v.push_back(false);
v.push_back(true);
for(vector<bool>::iterator i = v.begin(); i != v.end(); i++)
{
cout << *i << " ";
}
cout<< endl;
vector<bool>v2;
v2.resize(v.size());
transform(v.begin(), v.end(), v2.begin(), logical_not<bool>());
for(vector<bool>::iterator i = v2.begin(); i != v2.end(); i++)
{
cout << *i << " ";
}
}
int main()
{
test();
test2();
test3();
test4();
return 0;
system("pause");
}