fork download
  1. #include <iostream>
  2.  
  3. namespace foo {
  4. struct Foo {};
  5.  
  6. template <typename T>
  7. void func(T t) {
  8. std::cout << "namespace function\n";
  9. }
  10. }
  11.  
  12. template <typename T>
  13. void func(T t) {
  14. std::cout << "global function\n";
  15. }
  16.  
  17. int main() {
  18. foo::Foo f;
  19. func(f);
  20. }
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19: error: call of overloaded ‘func(foo::Foo&)’ is ambiguous
prog.cpp:13: note: candidates are: void func(T) [with T = foo::Foo]
prog.cpp:7: note:                 void foo::func(T) [with T = foo::Foo]
stdout
Standard output is empty