fork download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. int item = 42;
  5. struct TypeWithoutLeftShift { int n; } item2;
  6.  
  7. namespace operators_fallback
  8. {
  9. template <typename T>
  10. inline std::stringstream& operator<<(std::stringstream& s, const T &) { s.write("24", 2); return s; }
  11. };
  12.  
  13. template <typename T>
  14. inline std::string toString(const T& t)
  15. {
  16. using namespace operators_fallback;
  17. std::stringstream s;
  18. s << t;
  19. return s.str();
  20. }
  21.  
  22. int main( void )
  23. {
  24. std::cout << toString( item ) << std::endl;
  25. std::cout << toString( item2 ) << std::endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
24
24