Skip to content

Instantly share code, notes, and snippets.

@limansky
Created December 11, 2012 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save limansky/4262706 to your computer and use it in GitHub Desktop.
Save limansky/4262706 to your computer and use it in GitHub Desktop.
using bind1st
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
bool gt(int a, int b)
{
return a < b;
}
int main()
{
int d[] = {1,2,5,7,33,12};
vector<int> v(d, d + sizeof(d)/ sizeof(int));
vector<int>::iterator i = find_if(v.begin(), v.end(), bind1st(ptr_fun(&gt), 7));
if (i != v.end())
cout << "Found i=" << *i;
else
cout << "Not found";
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment