I’d like implement class MyCout, which can provide possibility of automatic endl, i.e. this code
MyCout mycout;
mycout<<1<<2<<3;
outputs
123
//empty line here
Is it possible to implement class with such functionality?
UPDATE:
Soulutions shouldn’t be like that MyCout()<<1<<2<<3; i.e. they should be without creating temporary object
This is simply a variant of Rob’s answer, that doesn’t use the heap. It’s a big enough change that I didn’t want to just change his answer though