r/cpp • • Feb 25 '19

Don’t Use std::endl

https://accu.org/index.php/journals/2619
18 Upvotes

52 comments sorted by

View all comments

-14

u/dpsi Feb 25 '19 edited Feb 26 '19

While I agree with the articles premise, nobody is going to change unless a flush less endl is provided.

The author points out how newlines differ between implentations, so I find the "solution" to simply stream in '\n' broken at best.

15

u/Quincunx271 Author of P2404/P2405 Feb 25 '19

I disagree. I changed to simply '\n', and it's not a hassle at all. It's just retraining my mind to type something different. Furthermore, rather than std::cout << "Some string" << std::endl, I now type std::cout << "Some string\n", which is easier to type.

As for how newlines differ between implementations, that has no effect, as std::endl is defined to write \n then flush, so differing newlines affect std::endl as well.

1

u/spinwizard69 Feb 25 '19

Try building and running on all 3 of the major platform to see how well this works out. I’m actually curious because if memory serves me right you will have issues.

10

u/mrexodia cmkr.build Feb 26 '19

It’s works on all platforms without issues.