Created
December 11, 2012 22:04
-
-
Save limansky/4262706 to your computer and use it in GitHub Desktop.
using bind1st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(>), 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