fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4.  
  5. template<typename T>
  6. struct Base
  7. {
  8. void foo(const T&) {
  9. std::cout << __PRETTY_FUNCTION__ << std::endl ;
  10. }
  11.  
  12. };
  13.  
  14. template <typename ...Args>
  15. struct Magic : public Base<Args>... { };
  16.  
  17. int main (void)
  18. {
  19. Magic<int, std::string> magic ;
  20.  
  21. int i = 1;
  22. magic.foo(i) ;
  23. std::string s="s" ;
  24. magic.foo(s) ;
  25.  
  26. return 0 ;
  27.  
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:22:9: error: request for member 'foo' is ambiguous
   magic.foo(i) ;
         ^
prog.cpp:8:8: note: candidates are: void Base<T>::foo(const T&) [with T = std::basic_string<char>]
   void foo(const T&) {
        ^
prog.cpp:8:8: note:                 void Base<T>::foo(const T&) [with T = int]
prog.cpp:24:9: error: request for member 'foo' is ambiguous
   magic.foo(s) ;
         ^
prog.cpp:8:8: note: candidates are: void Base<T>::foo(const T&) [with T = std::basic_string<char>]
   void foo(const T&) {
        ^
prog.cpp:8:8: note:                 void Base<T>::foo(const T&) [with T = int]
stdout
Standard output is empty