template <class ForwardIterator1, class ForwardIterator2> void find_first_of( ForwardIterator1 xFirst1, ForwardIterator1 xLast1, ForwardIterator2 xFirst2, ForwardIterator2 xLast2 );
#include <algorithm>
template <class ForwardIterator1, class ForwardIterator2, class Predicate> void find_first_of( ForwardIterator1 xFirst1, ForwardIterator1 xLast1, ForwardIterator2 xFirst2, ForwardIterator2 xLast2, Predicate xTest );
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
using namespace std;
// Create a vector instance
vector<char> qV;
qV.push_back('X');
qV.push_back('o');
qV.push_back('a');
qV.push_back('X');
qV.push_back('.');
qV.push_back('n');
qV.push_back('e');
qV.push_back('t');
vector<char>::iterator qIter;
// Output the vector
cout << "Vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Search for any of these entries
cout << "Searching for the first of any: ";
for (qIter = qV.begin() + 3; qIter != qV.begin() + 5; ++qIter) {
cout << *qIter;
}
cout << endl;
qIter = find_first_of(qV.begin(), qV.end(), qV.begin() + 3, qV.begin() + 5);
// Output the vector after the find
cout << "Found entry and beyond: ";
for (; qIter != qV.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.