#include <string>
#include <list>
#include <iostream>
struct A {
std::string name;
A(const std::string& name) : name(name) {}
};
struct pA_comp {
bool operator() (const A* left, const A* right) const {
return left->name < right->name;
}
};
int main()
{
std::list<A*> list = {new A("c"), new A("a"), new A("b")};
list.sort(pA_comp());
for(auto i = list.begin(); i!=list.end(); ++i)
{
std::cout << (*i)->name << '\n';
delete *i;
}
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxpb3N0cmVhbT4Kc3RydWN0IEEgewogICAgc3RkOjpzdHJpbmcgbmFtZTsKICAgIEEoY29uc3Qgc3RkOjpzdHJpbmcmIG5hbWUpIDogbmFtZShuYW1lKSB7fQp9OwoKc3RydWN0IHBBX2NvbXAgewogICAgYm9vbCBvcGVyYXRvcigpIChjb25zdCBBKiBsZWZ0LCBjb25zdCBBKiByaWdodCkgY29uc3QgeyAKICAgICAgIHJldHVybiBsZWZ0LT5uYW1lIDwgcmlnaHQtPm5hbWU7CiAgICB9Cn07CmludCBtYWluKCkKewogICAgc3RkOjpsaXN0PEEqPiBsaXN0ID0ge25ldyBBKCJjIiksIG5ldyBBKCJhIiksIG5ldyBBKCJiIil9OwogICAgbGlzdC5zb3J0KHBBX2NvbXAoKSk7CgogICAgZm9yKGF1dG8gaSA9IGxpc3QuYmVnaW4oKTsgaSE9bGlzdC5lbmQoKTsgKytpKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCAoKmkpLT5uYW1lIDw8ICdcbic7CiAgICAgICAgZGVsZXRlICppOwogICAgfQp9Cg==