fork download
  1. #include <iostream>
  2.  
  3. class console {};
  4.  
  5. template<typename T>
  6. console& operator<<(console con, const T& val) {
  7. std::cout << val;
  8. return con;
  9. }
  10.  
  11. int main() {
  12. console c;
  13. c << "hello world" << std::endl;
  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: error: no match for ‘operator<<’ in ‘operator<< [with T = char [12]]((c, console()), ((const char (&)[12])"hello world")) << std::endl’
prog.cpp: In function ‘console& operator<<(console, const T&) [with T = char [12]]’:
prog.cpp:13:   instantiated from here
prog.cpp:6: warning: reference to local variable ‘con’ returned
stdout
Standard output is empty