No. std::endl isn’t a newline constant. It’s a manipulator which, in addition to inserting a newline, also flushes the stream.
If you just want to add a newline, you’re supposed to just insert a ‘n’. And if you just want to add a tab, you just insert a ‘t’. There’s no std::tab or anything because inserting a tab plus flushing the stream is not exactly a common operation.
If you want to add the feature yourself, it would look like this:
#include
namespace std {
template
inline basic_ostream<_CharT, _Traits> &
tab(basic_ostream<_CharT, _Traits> &__os) {
return __os.put(__os.widen(‘t’));
}
}
int main() {
std::cout << "hello" << std::endl; std::cout << std::tab << "world" << std::endl; } I don't recommend doing this, but I wanted to add a solution for completeness.