fork download
  1. #include <iostream>
  2. #include <sstream> //for std::ostringstream
  3.  
  4. struct Trace
  5. {
  6. std::ostringstream ss;
  7.  
  8. template<typename T>
  9. Trace& operator << (T const & data)
  10. {
  11. ss << data;
  12. return *this;
  13. }
  14. ~Trace()
  15. {
  16. std::cout << ss.str() << std::endl;
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. Trace() << "Hello World\n" << 100 << "\nBye\n";
  23. }
Success #stdin #stdout 0.01s 2860KB
stdin
Standard input is empty
stdout
Hello World
100
Bye