language: C++11 (gcc-4.7.2)
date: 136 days 11 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
void f(int x) { }
int f(const int & x) { return x; }
 
int main()
{
    // ambiguous call
    f(42);
    
    // even when we call it using a const ref, it's ambiguous, so no hack possible...
    int arg = 42;
    const int &argR = arg;
    f(argR);
}
prog.cpp: In function 'int main()':
prog.cpp:8:9: error: call of overloaded 'f(int)' is ambiguous
prog.cpp:2:6: note: candidates are: void f(int)
prog.cpp:3:5: note:                 int f(const int&)
prog.cpp:13:11: error: call of overloaded 'f(const int&)' is ambiguous
prog.cpp:2:6: note: candidates are: void f(int)
prog.cpp:3:5: note:                 int f(const int&)