Mega Code Archive

 
Categories / C++ Tutorial / STL Algorithms Modifying Sequence Operations
 

Removeif, bind2nd() and list

#include <iostream> #include <list> #include <functional> #include <algorithm> using namespace std;     int main() {   list<int> list1;   list<int>::iterator p, endp;       int i;       for(i=1; i < 20; i++) list1.push_back(i);       p = list1.begin();   while(p != list1.end()) {     cout << *p << endl;     p++;   }   endp = remove_if(list1.begin(), list1.end(),bind2nd(greater<int>(), 4));       p = list1.begin();   while(p != endp) {     cout << *p << endl;     p++;   }   return 0; }