Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jflopezfernandez/f03cd1ca566f48a319052c7b0d2e0938 to your computer and use it in GitHub Desktop.
Save jflopezfernandez/f03cd1ca566f48a319052c7b0d2e0938 to your computer and use it in GitHub Desktop.
/** Dietmar Kuhl, the C++ IO and Internationalization expert, wrote this blogpost
* (https://kuhllib.com/2012/01/14/stop-excessive-use-of-stdendl/)
* discussing the need to stop overusing `std::endl`. In the blog post, he implemented
* this function as a replacement.
*
* While it looks almost exactly the same in use, this function only outputs a
* new line character; it does not flush the output stream. In contrast, `std::endl`
* both outputs a new character and calls `std::fflush()`.
*
* He also implements this function himself here:
* (https://github.com/dietmarkuehl/kuhllib/blob/master/blog/endl.cpp)
*
* I'm remaking it here just in case, but all credit belongs to him.
*
*/
#include <iostream>
template <typename T, typename Traits>
std::basic_ostream<T, Traits>&
NL (std::basic_ostream<T, Traits>& out)
{
return out << out.widen('\n');
}
int main()
{
std::cout << "Testing..." << NL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment