#include #include #include //for class string #include //for find_if #include //for bind2nd, mem_fun #include //for compose1 using namespace std; int main() { const string *a[] = { new string(""), new string("hello"), new string("goodbye") }; const size_t n = sizeof a / sizeof a[0]; const string *const *p = find_if(a, a + n, mem_fun(&string::size)); if (p == a + n) { cout << "Every string was of length 0.\n"; } else { cout << "The first non-empty string was a[" << p - a << "] == \"" << **p << "\".\n"; } p = find_if(a, a + n, __gnu_cxx::compose1( bind2nd(equal_to(), 7), mem_fun(&string::size) ) ); if (p == a + n) { cout << "No string was of length 7.\n"; } else { cout << "The first string of length 7 was a[" << p - a << "] == \"" << **p << "\".\n"; } for (const string *const *p = a + n - 1; p >= a; --p) { delete *p; } return EXIT_SUCCESS; }