Guys would it be difficult to write coutn which would basically place newline symbol at the end of the input. While working with console (that's all I can do at the moment) I'm finding very tedious to write '\n' every time I want the line to be a new line.
Or maybe it is already implemented?
To circumvent the multiple injections on a single line, you could use a temporary object. This temporary object would add the '\n' in its destructor.
struct coutn {
coutn(): os(cout) {}
~coutn() { os << '\n'; }
template <typename T>
coutn & operator<<(T const & x) { os << x; return *this; }
private:
ostream &os;
};
coutn() << "Hello " << "World" << "!";
In the end, I'm wondering if this coutn
is actually better?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With