Find the first of two values
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char** argv)
{
int elems[] = {5, 6, 9, 8, 8, 3};
vector<int> myVector(elems, elems + 6);
vector<int>::const_iterator it, it2;
// Find the first of two values
int targets[] = {8, 9};
it = find_first_of(myVector.begin(), myVector.end(), targets,targets + 2);
if (it != myVector.end()) {
cout << "Found one of 8 or 9: " << *it << endl;
}
return (0);
}
Related examples in the same category