#include <iostream>
class alloc
{
};
template <typename T, typename Alloc = alloc>
class vector
{
public:
void swap(vector<T,Alloc> &v) { std::cout << "swap()" << std::endl; }
};
template <typename T, typename Alloc>
void swap(const vector<T,Alloc> &v1,const vector<T,Alloc> &v2)
{
v1.swap(v2);
}
int main()
{
vector<int> x;
vector<int> y;
swap(x,y);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgYWxsb2MKewoKfTsKCnRlbXBsYXRlIDx0eXBlbmFtZSBULCB0eXBlbmFtZSBBbGxvYyA9IGFsbG9jPgpjbGFzcyB2ZWN0b3IKewpwdWJsaWM6CiAgICB2b2lkIHN3YXAodmVjdG9yPFQsQWxsb2M+ICZ2KSB7IHN0ZDo6Y291dCA8PCAic3dhcCgpIiA8PCBzdGQ6OmVuZGw7IH0KfTsKCgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVCwgdHlwZW5hbWUgQWxsb2M+CnZvaWQgc3dhcChjb25zdCB2ZWN0b3I8VCxBbGxvYz4gJnYxLGNvbnN0IHZlY3RvcjxULEFsbG9jPiAmdjIpCnsKICAgIHYxLnN3YXAodjIpOwp9CgppbnQgbWFpbigpCnsKICAgIHZlY3RvcjxpbnQ+IHg7CiAgICB2ZWN0b3I8aW50PiB5OwoKICAgIHN3YXAoeCx5KTsKCiAgICByZXR1cm4gMDsKfQo=
prog.cpp: In instantiation of 'void swap(const vector<T, Alloc>&, const vector<T, Alloc>&) [with T = int; Alloc = alloc]':
prog.cpp:27:13: required from here
prog.cpp:19:5: error: passing 'const vector<int>' as 'this' argument discards qualifiers [-fpermissive]
v1.swap(v2);
^
prog.cpp:12:10: note: in call to 'void vector<T, Alloc>::swap(vector<T, Alloc>&) [with T = int; Alloc = alloc]'
void swap(vector<T,Alloc> &v) { std::cout << "swap()" << std::endl; }
^
prog.cpp:19:5: error: binding 'const vector<int>' to reference of type 'vector<int>&' discards qualifiers
v1.swap(v2);
^
prog.cpp:12:10: note: initializing argument 1 of 'void vector<T, Alloc>::swap(vector<T, Alloc>&) [with T = int; Alloc = alloc]'
void swap(vector<T,Alloc> &v) { std::cout << "swap()" << std::endl; }
^