std::endl
is just an ordinary function (or rather, function template) that you can call. You just have to call it with the correct argument:
std::endl(std::cout); // OK, equivalent to "std::cout << std::endl;"
That's because the ostream
overloads the shift operator for function pointers, in a manner equivalent to the following:
ostream & operator<<(ostream & os, ostream & (*f)(ostream &))
{
return f(os);
}
(It will actually be a template for basic_ostream
to deal with any kind of character traits and allocators.)