fork(1) download
  1. #include <iostream>
  2.  
  3. namespace foo
  4. {
  5. void print(int x)
  6. {
  7. std::cout << "int=" << x << std::endl;
  8. }
  9. }
  10.  
  11. namespace bar
  12. {
  13. void print(float y)
  14. {
  15. std::cout << "float=" << y << std::endl;
  16. }
  17. }
  18.  
  19. namespace spam
  20. {
  21. struct ham
  22. {};
  23.  
  24. void print(const ham&)
  25. {
  26. std::cout << "got ham!" << std::endl;
  27. }
  28. }
  29.  
  30. template<typename T>
  31. void doit(T x)
  32. {
  33. using foo::print;
  34. using bar::print;
  35. print(x);
  36. }
  37.  
  38.  
  39. int main() {
  40. doit(5);
  41. doit(1.0f);
  42. doit(spam::ham());
  43. return 0;
  44. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
int=5
float=1
got ham!