0

I'm would like to modify a stream so that every time something is output to the stream each line is prepended with some number of tabs. It seems that a manipulator is the way to go about this but none of the examples I've found make it clear how to manipulate in this way.

Is this a reasonable thing for a manipulator and if so how?

Michael Conlen
  • 1,959
  • 2
  • 17
  • 19
  • Related : http://stackoverflow.com/q/30073287/3233393. Not a duplicate, but may be solved with the same pattern. – Quentin Jul 01 '16 at 14:04

1 Answers1

1

No, it's not reasonable. That would require you to detect whenever the stream output a new line, and then follow it up with a tab. In order to do that, you'd have to, at the very least, rewrite the put and write member functions of std::basic_ostream in such a way that they check for your manipulator's injected state, and act accordingly whenever they see a \n in the output. Definitely not reasonable.

Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274