They aren’t the same thing so the comparison is weird.
endl
has aflush
which is important when doing something like embedded work or RTOS development. If i was doing multiple lines they all were\n
until the last line when i actually want to push the buffer.Obviously depending on the tuning of the compiler’s optimization multiple flushes could be reduced but the goal should always be to write as optimal as possible.
Who in the hell is using iostreams in an RTOS
Sometimes you work in a codebase that was decided on by others for reasons you don’t know.
Endl is faster to type
If I’m writing C++, I’m usually optimizing for portability over performance, in which case I would prefer std::endl as it would yield the best results regardless of platform; it also keeps the end-of-line character out of other strings, making code just a little cleaner.
\n is for when I’m done pretending that anything that isn’t Unix-like is OK, or I’m counting the cycles of every branch instruction.
Rebel side
\0
\r\n gang
Are you a modem by any chance?
Get out
#define endl “\n”
os.linesep
Lol jk none of my stuff runs on Windows anyway
Well, Java has System.lineSeparator so, maybe no?
Environment.NewLine might exist in C#
Microsoft really creating the problem and then forcing you to use their solution.