fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct clear_line { } cls;
  5.  
  6. class out {
  7. private:
  8. std::ostream &strm = std::cout;
  9. bool is_next_clear = false;
  10. public:
  11. template <typename T>
  12. out& operator<<(const T& obj) {
  13. if(is_next_clear) {
  14. strm << std::endl << std::endl << std::endl; // clear logic
  15. is_next_clear = false;
  16. }
  17.  
  18. strm << obj;
  19. return *this;
  20. }
  21.  
  22. out& operator<<(const clear_line& _) {
  23. is_next_clear = true;
  24. return *this;
  25. }
  26. };
  27.  
  28. int main() {
  29. out o;
  30. o << "Some real output" << cls;
  31. o << "Some other real output";
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 4960KB
stdin
Standard input is empty
stdout
Some real output


Some other real output