fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. template <typename T>
  5. void print(const std::basic_string<T>& a, const std::basic_string<T>& b)
  6. {
  7. std::cout << a << b << std::endl;
  8. }
  9.  
  10. int main()
  11. {
  12. std::string bar = "bar";
  13. print("foo", bar);
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:21: error: no matching function for call to ‘print(const char [4], std::string&)’
     print("foo", bar);
                     ^
prog.cpp:13:21: note: candidate is:
prog.cpp:5:6: note: template<class T> void print(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
 void print(const std::basic_string<T>& a, const std::basic_string<T>& b)
      ^
prog.cpp:5:6: note:   template argument deduction/substitution failed:
prog.cpp:13:21: note:   mismatched types ‘const std::basic_string<_CharT>’ and ‘const char [4]’
     print("foo", bar);
                     ^
stdout
Standard output is empty