#include <iostream>
#include <algorithm>
namespace foo
{
struct Bar
{
int data;
};
void swap(Bar& a, Bar& b)
{
std::cout << "foo::swap" << std::endl;
int temp = a.data;
a.data = b.data;
b.data = temp;
}
}
int main()
{
foo::Bar bar1, bar2;
bar1.data = 42;
bar2.data = 777;
std::cout << bar1.data << ' ' << bar2.data << std::endl;
using std::swap;
swap(bar1, bar2); // Call foo::swap not std::swap.
std::cout << bar1.data << ' ' << bar2.data << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKbmFtZXNwYWNlIGZvbwp7CiAgICBzdHJ1Y3QgQmFyCiAgICB7CiAgICAgICAgaW50IGRhdGE7CiAgICB9OwogICAgCiAgICB2b2lkIHN3YXAoQmFyJiBhLCBCYXImIGIpCiAgICB7CiAgICAgICAgc3RkOjpjb3V0IDw8ICJmb286OnN3YXAiIDw8IHN0ZDo6ZW5kbDsKICAgIAogICAgICAgIGludCB0ZW1wID0gYS5kYXRhOwogICAgICAgIGEuZGF0YSA9IGIuZGF0YTsKICAgICAgICBiLmRhdGEgPSB0ZW1wOwogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGZvbzo6QmFyIGJhcjEsIGJhcjI7CiAgICAKICAgIGJhcjEuZGF0YSA9IDQyOwogICAgYmFyMi5kYXRhID0gNzc3OwogICAgCiAgICBzdGQ6OmNvdXQgPDwgYmFyMS5kYXRhIDw8ICcgJyA8PCBiYXIyLmRhdGEgPDwgc3RkOjplbmRsOwogICAgCiAgICB1c2luZyBzdGQ6OnN3YXA7CiAgICBzd2FwKGJhcjEsIGJhcjIpOyAvLyBDYWxsIGZvbzo6c3dhcCBub3Qgc3RkOjpzd2FwLgogICAgCiAgICBzdGQ6OmNvdXQgPDwgYmFyMS5kYXRhIDw8ICcgJyA8PCBiYXIyLmRhdGEgPDwgc3RkOjplbmRsOwogICAgCiAgICByZXR1cm4gMDsKfQ==