fork download
  1.  
  2. void f(int x) { }
  3. int f(const int & x) { return x; }
  4.  
  5. int main()
  6. {
  7. // ambiguous call
  8. f(42);
  9.  
  10. // even when we call it using a const ref, it's ambiguous, so no hack possible...
  11. int arg = 42;
  12. const int &argR = arg;
  13. f(argR);
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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&)
stdout
Standard output is empty