#include <iostream>
#include <functional>
#include <memory>
struct Test{
int a;
void func(int i){
std::cout << "Quark!" << i + a << std::endl;
}
Test(int v) : a(v){
}
};
int main() {
Test t = 10;
auto ptr = &t;
auto unip = std::unique_ptr<Test>(new Test(100));
auto func = std::mem_fn(&Test::func);
func(t,1);
func(ptr,2);
func(unip,3);
auto a = std::mem_fn(&Test::a);
a(t) = 10;
a(ptr) = 20;
a(unip) = 30;
func(t,1);
func(ptr,2);
func(unip,3);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPG1lbW9yeT4KCnN0cnVjdCBUZXN0ewoJaW50IGE7Cgl2b2lkIGZ1bmMoaW50IGkpewoJCXN0ZDo6Y291dCA8PCAiUXVhcmshIiA8PCBpICsgYSA8PCBzdGQ6OmVuZGw7Cgl9CgkKCVRlc3QoaW50IHYpIDogYSh2KXsKCX0KfTsKCmludCBtYWluKCkgewoJVGVzdCB0ID0gMTA7CglhdXRvIHB0ciA9ICZ0OwoJYXV0byB1bmlwID0gc3RkOjp1bmlxdWVfcHRyPFRlc3Q+KG5ldyBUZXN0KDEwMCkpOwoJCglhdXRvIGZ1bmMgPSBzdGQ6Om1lbV9mbigmVGVzdDo6ZnVuYyk7CglmdW5jKHQsMSk7CglmdW5jKHB0ciwyKTsKCWZ1bmModW5pcCwzKTsKCQoJYXV0byBhID0gc3RkOjptZW1fZm4oJlRlc3Q6OmEpOwoJYSh0KSA9IDEwOwoJYShwdHIpID0gMjA7CglhKHVuaXApID0gMzA7CgkKCWZ1bmModCwxKTsKCWZ1bmMocHRyLDIpOwoJZnVuYyh1bmlwLDMpOwoJCglyZXR1cm4gMDsKfQ==