1// find_if example
2#include <iostream> // std::cout
3#include <algorithm> // std::find_if
4#include <vector> // std::vector
5
6bool IsOdd (int i) {
7 return ((i%2)==1);
8}
9
10int main () {
11 std::vector<int> myvector;
12
13 myvector.push_back(10);
14 myvector.push_back(25);
15 myvector.push_back(40);
16 myvector.push_back(55);
17
18 std::vector<int>::iterator it = std::find_if (myvector.begin(), myvector.end(), IsOdd);
19 std::cout << "The first odd value is " << *it << '\n';
20
21 return 0;
22}