#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
using namespace std;
void print(int elem)
{
cout << elem << " ";
}
int main(int argc, char** argv)
{
vector<int> myVector;
myVector.push_back(1);
myVector.push_back(2);
myVector.push_back(3);
myVector.push_back(4);
myVector.push_back(5);
myVector.push_back(6);
replace_if(myVector.begin(), myVector.end(), bind2nd(less<int>(), 0), 0);
replace_if(myVector.begin(), myVector.end(), bind2nd(greater<int>(), 100),100);
for_each(myVector.begin(), myVector.end(), &print);
cout << endl;
return (0);
}
|