template <class InputIterator, class Predicate> bool is_partitioned( InputIterator xFirst, InputIterator xLast, Predicate xTest );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
bool NotDotNet(char cChar) {
return ((cChar != '.') &&
(cChar != 'n') &&
(cChar != 'e') &&
(cChar != 't'));
}
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;
}
// Partition test
bool bIsPart = is_partitioned(qV.begin(), qV.end(), NotDotNet);
cout << (bIsPart ? " is " : " is not ") << "partitioned." << endl;
// Change one letter
qV[5] = 'p';
// Output the new vector
cout << "The vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter;
}
// Partition test
bIsPart = is_partitioned(qV.begin(), qV.end(), NotDotNet);
cout << (bIsPart ? " is " : " is not ") << "partitioned." << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.