negators with find_if, not1, greater_equals : not1 « STL Algorithms Helper « C++ Tutorial






#include <algorithm>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;

int main(int argc, char** argv)
{
  int num;

  vector<int> myVector;
  myVector.push_back(1);
  myVector.push_back(2);
  myVector.push_back(3);
  myVector.push_back(4);

  vector<int>::iterator it = find_if(myVector.begin(), myVector.end(),not1(bind2nd(greater_equal<int>(), 1)));
  if (it == myVector.end()) {
    cout << "All perfect scores\n";
  } else {
    cout << "Found a \"less-than-perfect\" score of " << *it << endl;
  }
  return (0);
}








32.17.not1
32.17.1.Use not1() to reverse sort v
32.17.2.Use not2() to remove all characters that are not equal to H
32.17.3.negators with find_if, not1, greater_equals