#include #include #include //for strlen #include //for find_if using namespace std; /* /opt/gcc450/bin/g++ -std=c++0x find_if2.C */ . int main() { const char *const a[] = {"", "hello", "goodbye"}; const size_t n = sizeof a / sizeof a[0]; const char *const *p = find_if(a, a + n, strlen); 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, [] (const char *p) {return strlen(p) == 7;}); 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"; } return EXIT_SUCCESS; }