#include <iostream>
#include <algorithm>
namespace foo
{
struct Bar
{
int data;
};
void init(Bar& bar)
{
bar.data = 42;
}
}
void init(foo::Bar& bar)
{
bar.data = 777;
}
int main()
{
foo::Bar bar;
init(bar) // Error! call of overloaded 'init(foo::Bar&)' is ambiguous.
std::cout << bar.data << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKbmFtZXNwYWNlIGZvbwp7CiAgICBzdHJ1Y3QgQmFyCiAgICB7CiAgICAgICAgaW50IGRhdGE7CiAgICB9OwogICAgCiAgICB2b2lkIGluaXQoQmFyJiBiYXIpCiAgICB7CiAgICAgICAgYmFyLmRhdGEgPSA0MjsKICAgIH0KfQoKdm9pZCBpbml0KGZvbzo6QmFyJiBiYXIpCnsKICAgIGJhci5kYXRhID0gNzc3Owp9CgppbnQgbWFpbigpCnsKICAgIGZvbzo6QmFyIGJhcjsKICAgIGluaXQoYmFyKSAvLyBFcnJvciEgY2FsbCBvZiBvdmVybG9hZGVkICdpbml0KGZvbzo6QmFyJiknIGlzIGFtYmlndW91cy4KICAgIAogICAgc3RkOjpjb3V0IDw8IGJhci5kYXRhIDw8IHN0ZDo6ZW5kbDsKICAgIAogICAgcmV0dXJuIDA7Cn0=
prog.cpp: In function ‘int main()’:
prog.cpp:25:13: error: call of overloaded ‘init(foo::Bar&)’ is ambiguous
init(bar) // Error! call of overloaded 'init(foo::Bar&)' is ambiguous.
^
prog.cpp:17:6: note: candidate: void init(foo::Bar&)
void init(foo::Bar& bar)
^~~~
prog.cpp:11:10: note: candidate: void foo::init(foo::Bar&)
void init(Bar& bar)
^~~~