#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
using namespace std;
int main()
{
vector<char *> vectorObject;
vector<char *>::iterator p;
int i;
vectorObject.push_back("One");
vectorObject.push_back("Two");
vectorObject.push_back("Three");
vectorObject.push_back("Four");
vectorObject.push_back("Five");
cout << "Sequence contains:";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[ i ] << " ";
cout << endl;
cout << "Searching sequence for Three.\n";
// use a pointer-to-function adaptor
p = find_if(vectorObject.begin(), vectorObject.end(), not1(bind2nd(ptr_fun(strcmp), "Three")));
if(p != vectorObject.end()) {
cout << "Found.";
cout << "Sequence from that point is:";
do {
cout << *p++ << " ";
} while (p != vectorObject.end());
}
return 0;
}
|