template <class InputIterator, class Predicate> bool none_of( InputIterator xFirst, InputIterator xLast, Predicate xTest );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
bool IsX(char cChar) {
return (cChar == 'X');
}
bool IsZ(char cChar) {
return (cChar == 'Z');
}
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 << "The Vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Check for X and Z
bool bNoneAre = none_of(qV.begin(), qV.end(), IsX);
cout << "There " << (bNoneAre ? "is not" : "is")
<< " an X in the vector." << endl;
bNoneAre = none_of(qV.begin(), qV.end(), IsZ);
cout << "There " << (bNoneAre ? "is not" : "is")
<< " a Z in the vector." << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.