#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <ext/functional>
struct Person {
std::string name;
Person(const std::string& n) : name(n) {}
std::string getName() const { return name; }
};
int main()
{
std::vector<Person*> vec;
vec.push_back(new Person("Arthur"));
vec.push_back(new Person("Chad"));
vec.push_back(new Person("Chad"));
ptrdiff_t num_chads = std::count_if(vec.begin(), vec.end(),
__gnu_cxx::compose1(
std::bind2nd(std::equal_to<std::string>(), "Chad"),
std::mem_fun(&Person::getName)));
std::cout << "There are " << num_chads << " chads\n";
delete vec[0]; delete vec[1]; delete vec[2];
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPGV4dC9mdW5jdGlvbmFsPgpzdHJ1Y3QgUGVyc29uIHsKICAgICAgICBzdGQ6OnN0cmluZyBuYW1lOwogICAgICAgIFBlcnNvbihjb25zdCBzdGQ6OnN0cmluZyYgbikgOiBuYW1lKG4pIHt9CiAgICAgICAgc3RkOjpzdHJpbmcgZ2V0TmFtZSgpIGNvbnN0IHsgcmV0dXJuIG5hbWU7IH0KfTsKCmludCBtYWluKCkKewogICAgICAgIHN0ZDo6dmVjdG9yPFBlcnNvbio+IHZlYzsKICAgICAgICB2ZWMucHVzaF9iYWNrKG5ldyBQZXJzb24oIkFydGh1ciIpKTsKICAgICAgICB2ZWMucHVzaF9iYWNrKG5ldyBQZXJzb24oIkNoYWQiKSk7CiAgICAgICAgdmVjLnB1c2hfYmFjayhuZXcgUGVyc29uKCJDaGFkIikpOwoKICAgICAgICBwdHJkaWZmX3QgbnVtX2NoYWRzID0gc3RkOjpjb3VudF9pZih2ZWMuYmVnaW4oKSwgdmVjLmVuZCgpLAogICAgICAgICAgICAgICAgICAgICAgIF9fZ251X2N4eDo6Y29tcG9zZTEoCiAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpiaW5kMm5kK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