fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<class T>
  5. struct Foo{
  6. template<class S>
  7.  
  8. Foo(S* s):_t(s){}
  9. T * _t;
  10. };
  11.  
  12. struct Bar{};
  13.  
  14. void do_something(Foo<Bar> f){
  15. cout<<"In Foo do something"<<endl;
  16. }
  17.  
  18. // void do_something(std::string f){
  19. // cout<<"In string do something"<<endl;
  20.  
  21. // }
  22.  
  23. int main() {
  24. const char * string = "string";
  25. do_something(string);
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'Foo<T>::Foo(S*) [with S = const char; T = Bar]':
prog.cpp:25:21:   required from here
prog.cpp:8:15: error: cannot convert 'const char*' to 'Bar*' in initialization
 Foo(S* s):_t(s){}
               ^
stdout
Standard output is empty