#include <algorithm>
#include <functional>
#include <iostream>
class A
{
std::reference_wrapper<int> r;
public:
A(int& v) : r(v) {}
void swap(A& rhs)
{
std::swap(r, rhs.r);
}
int& get() const { return r; }
};
int main()
{
int i = 42;
int j = 0;
A a(i), b(j);
a.swap(b);
++j;
std::cout << j << "==" << a.get() << std::endl;
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCmNsYXNzIEEKewogICAgc3RkOjpyZWZlcmVuY2Vfd3JhcHBlcjxpbnQ+IHI7CnB1YmxpYzoKICAgQShpbnQmIHYpIDogcih2KSB7fQogICB2b2lkIHN3YXAoQSYgcmhzKQogICB7CiAgICAgIHN0ZDo6c3dhcChyLCByaHMucik7CiAgIH0KCiAgIGludCYgZ2V0KCkgY29uc3QgeyByZXR1cm4gcjsgfQp9OwoKaW50IG1haW4oKQp7CiAgICBpbnQgaSA9IDQyOwogICAgaW50IGogPSAwOwogICAgQSBhKGkpLCBiKGopOwoKICAgIGEuc3dhcChiKTsKICAgICsrajsKICAgIHN0ZDo6Y291dCA8PCBqIDw8ICI9PSIgPDwgYS5nZXQoKSA8PCBzdGQ6OmVuZGw7CiAgICByZXR1cm4gMDsKfQo=