Name
operator<< function template — Writes a string to an output stream
Synopsis
template<class charT, class traits, class Allocator> basic_ostream<charT, traits>& operator<<( basic_ostream<charT, traits>& out, const basic_string<charT,traits,Allocator>& str); // ostream& operator<<(ostream& out, const string& str);
The <<
operator
writes the string str
to out
. Like any formatted output function,
it first creates a sentry object, and if the sentry evaluates to
true
, it writes the string
contents by calling out.rdbuf(
)->sputn
. If str.size(
)
<
out.width( )
, fill characters are added to
achieve the desired width. If sputn
fails, ios_base::failbit
is set.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.