template <class InputIterator, class Predicate> bool all_of( InputIterator qFirst, InputIterator qLast, Predicate qTester );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
bool AllAreX(char cChar) {
return (cChar == 'X');
}
int main()
{
using namespace std;
// Create two vector instances
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');
// Test all entries of the vector
bool bAllAreX = all_of(qV.begin(), qV.end(), AllAreX);
cout << "All entries " << (bAllAreX ? "are" : "are not") << " X" << endl;
vector<char>::iterator qIter = qV.begin();
++qIter;
// Test the first entry of the vector
bAllAreX = all_of(qV.begin(), qIter, AllAreX);
cout << "All entries " << (bAllAreX ? "are" : "are not") << " X" << endl;
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.