[output.streams]

# 31 Input/output library [[input.output]](./#input.output)

## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#output.streams)

### 31.7.6 Output streams [output.streams]

#### [31.7.6.1](#general) General [[output.streams.general]](output.streams.general)

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5912)

The header [<ostream>](ostream.syn#header:%3costream%3e "31.7.2 Header <ostream> synopsis [ostream.syn]") defines a class template
and several function templates that control output to a stream buffer,
along with a function template that inserts into stream rvalues[.](#general-1.sentence-1)

#### [31.7.6.2](#ostream) Class template basic_ostream [[ostream]](ostream)

#### [31.7.6.2.1](#ostream.general) General [[ostream.general]](ostream.general)

[1](#ostream.general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5921)

When a function has
a parameter type *extended-floating-point-type*,
the implementation provides overloads
for all cv-unqualified extended floating-point types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#ostream.general-1.sentence-1)

[ð](#lib:basic_ostream)

namespace std {template<class charT, class traits = char_traits<charT>>class basic_ostream : virtual public basic_ios<charT, traits> {public:// types (inherited from [basic_ios](ios "31.5.4 Class template basic_­ios [ios]"))using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[ostream.cons]](#ostream.cons "31.7.6.2.2 Constructors"), constructor/destructorexplicit basic_ostream(basic_streambuf<char_type, traits>* sb); virtual ~basic_ostream(); // [[ostream.sentry]](#ostream.sentry "31.7.6.2.4 Class basic_­ostream​::​sentry"), prefix/suffixclass sentry; // [[ostream.formatted]](#ostream.formatted "31.7.6.3 Formatted output functions"), formatted output basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
 basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
 basic_ostream& operator<<(ios_base& (*pf)(ios_base&));

 basic_ostream& operator<<(bool n);
 basic_ostream& operator<<(short n);
 basic_ostream& operator<<(unsigned short n);
 basic_ostream& operator<<(int n);
 basic_ostream& operator<<(unsigned int n);
 basic_ostream& operator<<(long n);
 basic_ostream& operator<<(unsigned long n);
 basic_ostream& operator<<(long long n);
 basic_ostream& operator<<(unsigned long long n);
 basic_ostream& operator<<(float f);
 basic_ostream& operator<<(double f);
 basic_ostream& operator<<(long double f);
 basic_ostream& operator<<(*extended-floating-point-type* f);

 basic_ostream& operator<<(const void* p);
 basic_ostream& operator<<(const volatile void* p);
 basic_ostream& operator<<(nullptr_t);
 basic_ostream& operator<<(basic_streambuf<char_type, traits>* sb); // [[ostream.unformatted]](#ostream.unformatted "31.7.6.4 Unformatted output functions"), unformatted output basic_ostream& put(char_type c);
 basic_ostream& write(const char_type* s, streamsize n);

 basic_ostream& flush(); // [[ostream.seeks]](#ostream.seeks "31.7.6.2.5 Seek members"), seeks pos_type tellp();
 basic_ostream& seekp(pos_type);
 basic_ostream& seekp(off_type, ios_base::seekdir); protected:// [[ostream.cons]](#ostream.cons "31.7.6.2.2 Constructors"), copy/move constructor basic_ostream(const basic_ostream&) = delete;
 basic_ostream(basic_ostream&& rhs); // [[ostream.assign]](#ostream.assign "31.7.6.2.3 Assignment and swap"), assignment and swap basic_ostream& operator=(const basic_ostream&) = delete;
 basic_ostream& operator=(basic_ostream&& rhs); void swap(basic_ostream& rhs); }; // [[ostream.inserters.character]](#ostream.inserters.character "31.7.6.3.4 Character inserter function templates"), character inserterstemplate<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, charT); template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*); template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*); template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete;}

[2](#ostream.general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6060)

The class templatebasic_ostream defines a number of member function
signatures that assist in formatting and writing output to output sequences
controlled by a stream buffer[.](#ostream.general-2.sentence-1)

[3](#ostream.general-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6067)

Two groups of member function signatures share common properties:
the[*formatted output functions*](#def:formatted_output_functions) (or[*inserters*](#def:inserters))
and the[*unformatted output functions.*](#def:unformatted_output_functions.) Both groups of output functions generate (or[*insert*](#def:insert))
output[*characters*](#def:characters) by actions equivalent to callingrdbuf()->sputc(int_type)[.](#ostream.general-3.sentence-1)

They may use other public members ofbasic_ostream except that they shall not invoke any virtual members ofrdbuf() exceptoverflow(),xsputn(),
andsync()[.](#ostream.general-3.sentence-2)

[4](#ostream.general-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6091)

If one of these called functions throws an exception, then unless explicitly noted otherwise
the output function setsbadbit in the error state[.](#ostream.general-4.sentence-1)

Ifbadbit is set inexceptions(),
the output function
rethrows the exception without completing its actions, otherwise
it does not throw anything and proceeds as if the called function had returned
a failure indication[.](#ostream.general-4.sentence-2)

[5](#ostream.general-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6105)

[*Note [1](#ostream.general-note-1)*:

The deleted overloads of operator<< prevent formatting characters as integers and strings as pointers[.](#ostream.general-5.sentence-1)

â *end note*]

#### [31.7.6.2.2](#ostream.cons) Constructors [[ostream.cons]](ostream.cons)

[ð](#lib:basic_ostream,constructor)

`explicit basic_ostream(basic_streambuf<charT, traits>* sb);
`

[1](#ostream.cons-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6120)

*Effects*: Initializes the base class subobject withbasic_ios<charT, traits>​::​init(sb) ([[basic.ios.cons]](basic.ios.cons "31.5.4.2 Constructors"))[.](#ostream.cons-1.sentence-1)

[2](#ostream.cons-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6125)

*Postconditions*: rdbuf() == sb[.](#ostream.cons-2.sentence-1)

[ð](#lib:basic_ostream,constructor_)

`basic_ostream(basic_ostream&& rhs);
`

[3](#ostream.cons-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6136)

*Effects*: Move constructs from the rvalue rhs[.](#ostream.cons-3.sentence-1)

This is accomplished by default constructing the base class and callingbasic_ios<charT, traits>​::​move(rhs) to initialize the
base class[.](#ostream.cons-3.sentence-2)

[ð](#lib:basic_ostream,destructor)

`virtual ~basic_ostream();
`

[4](#ostream.cons-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6150)

*Remarks*: Does not perform any operations onrdbuf()[.](#ostream.cons-4.sentence-1)

#### [31.7.6.2.3](#ostream.assign) Assignment and swap [[ostream.assign]](ostream.assign)

[ð](#lib:operator=,basic_ostream)

`basic_ostream& operator=(basic_ostream&& rhs);
`

[1](#ostream.assign-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6164)

*Effects*: Equivalent to swap(rhs)[.](#ostream.assign-1.sentence-1)

[2](#ostream.assign-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6168)

*Returns*: *this[.](#ostream.assign-2.sentence-1)

[ð](#lib:swap,basic_ostream)

`void swap(basic_ostream& rhs);
`

[3](#ostream.assign-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6179)

*Effects*: Calls basic_ios<charT, traits>​::​swap(rhs)[.](#ostream.assign-3.sentence-1)

#### [31.7.6.2.4](#ostream.sentry) Class basic_ostream​::​sentry [[ostream.sentry]](ostream.sentry)

[ð](#lib:basic_ostream::sentry)

namespace std {template<class charT, class traits>class basic_ostream<charT, traits>::sentry {bool *ok_*; // *exposition only*public:explicit sentry(basic_ostream& os); ~sentry(); explicit operator bool() const { return *ok_*; } sentry(const sentry&) = delete;
 sentry& operator=(const sentry&) = delete; };}

[1](#ostream.sentry-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6205)

The classsentry defines a class that is responsible for doing exception safe prefix and suffix
operations[.](#ostream.sentry-1.sentence-1)

[ð](#lib:basic_ostream::sentry,constructor)

`explicit sentry(basic_ostream& os);
`

[2](#ostream.sentry-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6217)

Ifos.good() is nonzero, prepares for formatted or unformatted output[.](#ostream.sentry-2.sentence-1)

Ifos.tie() is not a null pointer, callsos.tie()->flush()[.](#ostream.sentry-2.sentence-2)[283](#footnote-283 "The call os.tie()->flush() does not necessarily occur if the function can determine that no synchronization is necessary.")

[3](#ostream.sentry-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6233)

If, after any preparation is completed,os.good() istrue,*ok_* == true otherwise,*ok_* == false[.](#ostream.sentry-3.sentence-1)

During preparation, the constructor may callsetstate(failbit) (which may throwios_base​::​​failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#ostream.sentry-3.sentence-2)[284](#footnote-284 "The sentry constructor and destructor can also perform additional implementation-dependent operations.")

[ð](#lib:basic_ostream::sentry,destructor)

`~sentry();
`

[4](#ostream.sentry-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6261)

If(os.flags() & ios_base​::​unitbuf) && !uncaught_exceptions()&& os.good() istrue,
callsos.rdbuf()->pubsync()[.](#ostream.sentry-4.sentence-1)

If that function returns â1 or
exits via an exception, sets badbit inos.rdstate() without propagating an exception[.](#ostream.sentry-4.sentence-2)

[ð](#lib:operator_bool,basic_ostream::sentry)

`explicit operator bool() const;
`

[5](#ostream.sentry-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6279)

*Effects*: Returns*ok_*[.](#ostream.sentry-5.sentence-1)

[283)](#footnote-283)[283)](#footnoteref-283)

The callos.tie()->flush() does not necessarily occur if the function can determine that no
synchronization is necessary[.](#footnote-283.sentence-1)

[284)](#footnote-284)[284)](#footnoteref-284)

Thesentry constructor and destructor
can also perform additionalimplementation-dependent operations[.](#footnote-284.sentence-1)

#### [31.7.6.2.5](#ostream.seeks) Seek members [[ostream.seeks]](ostream.seeks)

[1](#ostream.seeks-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6287)

Each seek member function begins execution by constructing an object of class sentry[.](#ostream.seeks-1.sentence-1)

It returns by destroying the sentry object[.](#ostream.seeks-1.sentence-2)

[ð](#lib:tellp,basic_ostream)

`pos_type tellp();
`

[2](#ostream.seeks-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6297)

*Returns*: Iffail() != false,
returnspos_type(-1) to indicate failure[.](#ostream.seeks-2.sentence-1)

Otherwise, returnsrdbuf()->​pubseekoff(​0, cur, out)[.](#ostream.seeks-2.sentence-2)

[ð](#lib:seekp,basic_ostream)

`basic_ostream& seekp(pos_type pos);
`

[3](#ostream.seeks-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6314)

*Effects*: Iffail() != true,
executesrdbuf()->pubseekpos(pos, ios_base​::​out)[.](#ostream.seeks-3.sentence-1)

In case of failure, the function callssetstate(failbit) (which may throwios_base​::​failure)[.](#ostream.seeks-3.sentence-2)

[4](#ostream.seeks-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6325)

*Returns*: *this[.](#ostream.seeks-4.sentence-1)

[ð](#lib:seekp,basic_ostream_)

`basic_ostream& seekp(off_type off, ios_base::seekdir dir);
`

[5](#ostream.seeks-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6336)

*Effects*: Iffail() != true,
executesrdbuf()->pubseekoff(off, dir, ios_base​::​out)[.](#ostream.seeks-5.sentence-1)

In case of failure, the function calls setstate(failbit) (which may throw ios_base​::​failure)[.](#ostream.seeks-5.sentence-2)

[6](#ostream.seeks-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6345)

*Returns*: *this[.](#ostream.seeks-6.sentence-1)

#### [31.7.6.3](#ostream.formatted) Formatted output functions [[ostream.formatted]](ostream.formatted)

#### [31.7.6.3.1](#ostream.formatted.reqmts) Common requirements [[ostream.formatted.reqmts]](ostream.formatted.reqmts)

[1](#ostream.formatted.reqmts-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6354)

Each formatted output function begins execution by constructing an object of classsentry[.](#ostream.formatted.reqmts-1.sentence-1)

If that object returnstrue when converted to a value of typebool,
the function endeavors
to generate the requested output[.](#ostream.formatted.reqmts-1.sentence-2)

If the generation fails, then the formatted output function doessetstate(ios_base​::​failbit),
which can throw an exception[.](#ostream.formatted.reqmts-1.sentence-3)

If an exception is thrown during output, thenios_base​::​badbit is set[285](#footnote-285 "This is done without causing an ios_­base​::​failure to be thrown.") in*this's
error state[.](#ostream.formatted.reqmts-1.sentence-4)

If(exceptions() & badbit) != 0 then the exception is rethrown[.](#ostream.formatted.reqmts-1.sentence-5)

Whether or not an exception is thrown, thesentry object is destroyed before leaving the formatted output function[.](#ostream.formatted.reqmts-1.sentence-6)

If no exception is thrown, the result of the formatted output function
is*this[.](#ostream.formatted.reqmts-1.sentence-7)

[2](#ostream.formatted.reqmts-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6387)

The descriptions of the individual formatted output functions
describe how they perform
output and do not mention thesentry object[.](#ostream.formatted.reqmts-2.sentence-1)

[3](#ostream.formatted.reqmts-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6394)

If a formatted output function of a stream os determines
padding, it does so as
follows[.](#ostream.formatted.reqmts-3.sentence-1)

Given a charT character sequence seq wherecharT is the character container type of the stream, if
the length of seq is less than os.width(), then enough copies ofos.fill() are added to this sequence as necessary to pad to a
width of os.width() characters[.](#ostream.formatted.reqmts-3.sentence-2)

If(os.flags() & ios_base​::​adjustfield) == ios_base​::​left istrue, the fill characters are placed
after the character sequence; otherwise, they are placed before the
character sequence[.](#ostream.formatted.reqmts-3.sentence-3)

[285)](#footnote-285)[285)](#footnoteref-285)

This is done without causing anios_base​::​failure to be thrown[.](#footnote-285.sentence-1)

#### [31.7.6.3.2](#ostream.inserters.arithmetic) Arithmetic inserters [[ostream.inserters.arithmetic]](ostream.inserters.arithmetic)

[ð](#lib:operator%3c%3c,basic_ostream)

`basic_ostream& operator<<(bool val);
basic_ostream& operator<<(short val);
basic_ostream& operator<<(unsigned short val);
basic_ostream& operator<<(int val);
basic_ostream& operator<<(unsigned int val);
basic_ostream& operator<<(long val);
basic_ostream& operator<<(unsigned long val);
basic_ostream& operator<<(long long val);
basic_ostream& operator<<(unsigned long long val);
basic_ostream& operator<<(float val);
basic_ostream& operator<<(double val);
basic_ostream& operator<<(long double val);
basic_ostream& operator<<(const void* val);
`

[1](#ostream.inserters.arithmetic-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6427)

*Effects*: The classesnum_get<> andnum_put<> handle locale-dependent numeric formatting and
parsing[.](#ostream.inserters.arithmetic-1.sentence-1)

These inserter functions use the imbuedlocale value to perform numeric formatting[.](#ostream.inserters.arithmetic-1.sentence-2)

When val is of typebool,long,unsigned long,long long, unsigned long long,double,long double,
orconst void*,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), val).failed();

When val is of typeshort the formatting conversion occurs as if it performed the following code fragment:ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(),
 baseflags == ios_base::oct || baseflags == ios_base::hex ? static_cast<long>(static_cast<unsigned short>(val)): static_cast<long>(val)).failed();

When val is of typeint the formatting conversion occurs as if it performed the following code fragment:ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(),
 baseflags == ios_base::oct || baseflags == ios_base::hex ? static_cast<long>(static_cast<unsigned int>(val)): static_cast<long>(val)).failed();

When val is of typeunsigned short orunsigned int the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<unsigned long>(val)).failed();

When val is of typefloat the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();

[2](#ostream.inserters.arithmetic-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6496)

The first argument provides an object of theostreambuf_iterator<> class which is an iterator for class basic_ostream<>[.](#ostream.inserters.arithmetic-2.sentence-1)

It bypassesostreams
and usesstreambufs
directly[.](#ostream.inserters.arithmetic-2.sentence-2)

Classlocale relies on these types as its
interface to iostreams, since for flexibility it has been abstracted
away from direct dependence onostream[.](#ostream.inserters.arithmetic-2.sentence-3)

The second parameter is a reference to the base class subobject of typeios_base[.](#ostream.inserters.arithmetic-2.sentence-4)

It provides formatting specifications such as field width, and
a locale from which to obtain other facets[.](#ostream.inserters.arithmetic-2.sentence-5)

Iffailed istrue then doessetstate(badbit),
which may throw an exception, and returns[.](#ostream.inserters.arithmetic-2.sentence-6)

[3](#ostream.inserters.arithmetic-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6523)

*Returns*: *this[.](#ostream.inserters.arithmetic-3.sentence-1)

[ð](#lib:operator%3c%3c,basic_ostream_)

`basic_ostream& operator<<(const volatile void* p);
`

[4](#ostream.inserters.arithmetic-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6534)

*Effects*: Equivalent to: return operator<<(const_cast<const void*>(p));

[ð](#ostream.inserters.arithmetic-itemdecl:3)

`basic_ostream& operator<<(extended-floating-point-type val);
`

[5](#ostream.inserters.arithmetic-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6544)

*Effects*: If the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();

Otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of long double,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<long double>(val)).failed();

Otherwise, an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#ostream.inserters.arithmetic-5.sentence-3)

If failed is true then does setstate(badbit),
which may throw an exception, and returns[.](#ostream.inserters.arithmetic-5.sentence-4)

[6](#ostream.inserters.arithmetic-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6568)

*Returns*: *this[.](#ostream.inserters.arithmetic-6.sentence-1)

#### [31.7.6.3.3](#ostream.inserters) basic_ostream​::​operator<< [[ostream.inserters]](ostream.inserters)

[ð](#lib:operator%3c%3c,basic_ostream__)

`basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
`

[1](#ostream.inserters-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6581)

*Effects*: None[.](#ostream.inserters-1.sentence-1)

Does not behave as a formatted output function (as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements"))[.](#ostream.inserters-1.sentence-2)

[2](#ostream.inserters-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6587)

*Returns*: pf(*this)[.](#ostream.inserters-2.sentence-1)[286](#footnote-286 "See, for example, the function signature endl(basic_­ostream&amp;) ([ostream.manip]).")

[ð](#lib:operator%3c%3c,basic_ostream___)

`basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
`

[3](#ostream.inserters-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6603)

*Effects*: Callspf(*this)[.](#ostream.inserters-3.sentence-1)

This inserter does not
behave as a formatted output function (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements"))[.](#ostream.inserters-3.sentence-2)

[4](#ostream.inserters-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6610)

*Returns*: *this[.](#ostream.inserters-4.sentence-1)[287](#footnote-287 "See, for example, the function signature dec(ios_­base&amp;) ([basefield.manip]).")

[ð](#lib:operator%3c%3c,basic_ostream____)

`basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
`

[5](#ostream.inserters-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6626)

*Effects*: Callspf(*this)[.](#ostream.inserters-5.sentence-1)

This inserter does not
behave as a formatted output function (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements"))[.](#ostream.inserters-5.sentence-2)

[6](#ostream.inserters-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6633)

*Returns*: *this[.](#ostream.inserters-6.sentence-1)

[ð](#lib:operator%3c%3c,basic_ostream_____)

`basic_ostream& operator<<(basic_streambuf<charT, traits>* sb);
`

[7](#ostream.inserters-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6644)

*Effects*: Behaves as an unformatted output function ([[ostream.unformatted]](#ostream.unformatted "31.7.6.4 Unformatted output functions"))[.](#ostream.inserters-7.sentence-1)

After the sentry object is
constructed, ifsb is null callssetstate(badbit) (which may throwios_base​::​failure)[.](#ostream.inserters-7.sentence-2)

[8](#ostream.inserters-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6654)

Gets characters from sb and inserts them in*this[.](#ostream.inserters-8.sentence-1)

Characters are read from sb and inserted until any of the following occurs:

- [(8.1)](#ostream.inserters-8.1)

end-of-file occurs on the input sequence;

- [(8.2)](#ostream.inserters-8.2)

inserting in the output sequence fails
(in which case the character to be inserted is not extracted);

- [(8.3)](#ostream.inserters-8.3)

an exception occurs while getting a character from sb[.](#ostream.inserters-8.sentence-2)

[9](#ostream.inserters-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6670)

If the function inserts no characters, it callssetstate(failbit) (which may throwios_base​::​​failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#ostream.inserters-9.sentence-1)

If an exception was thrown while extracting a character,
the function setsfailbit in the error state, and iffailbit is set inexceptions() the caught exception is rethrown[.](#ostream.inserters-9.sentence-2)

[10](#ostream.inserters-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6684)

*Returns*: *this[.](#ostream.inserters-10.sentence-1)

[ð](#lib:operator%3c%3c,basic_ostream______)

`basic_ostream& operator<<(nullptr_t);
`

[11](#ostream.inserters-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6695)

*Effects*: Equivalent to:return *this << s; where s is animplementation-defined[NTCTS](defns.ntcts "3.36 NTCTS [defns.ntcts]")[.](#ostream.inserters-11.sentence-1)

[286)](#footnote-286)[286)](#footnoteref-286)

See, for example, the function signatureendl(basic_ostream&) ([[ostream.manip]](#ostream.manip "31.7.6.5 Standard basic_­ostream manipulators"))[.](#footnote-286.sentence-1)

[287)](#footnote-287)[287)](#footnoteref-287)

See, for example, the function signaturedec(ios_base&) ([[basefield.manip]](basefield.manip "31.5.5.3 basefield manipulators"))[.](#footnote-287.sentence-1)

#### [31.7.6.3.4](#ostream.inserters.character) Character inserter function templates [[ostream.inserters.character]](ostream.inserters.character)

[ð](#lib:operator%3c%3c,basic_ostream_______)

`template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, charT c);
template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, char c);
// specialization
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, char c);
// signed and unsigned
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, signed char c);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
`

[1](#ostream.inserters.character-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6725)

*Effects*: Behaves as a [formatted output function](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements [ostream.formatted.reqmts]") of out[.](#ostream.inserters.character-1.sentence-1)

Constructs a character sequence seq[.](#ostream.inserters.character-1.sentence-2)

If c has typechar and the character container type of the stream is notchar,
then seq consists ofout.widen(c);
otherwise seq consists ofc[.](#ostream.inserters.character-1.sentence-3)

Determines padding for seq as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#ostream.inserters.character-1.sentence-4)

Inserts seq intoout[.](#ostream.inserters.character-1.sentence-5)

Calls os.width(0)[.](#ostream.inserters.character-1.sentence-6)

[2](#ostream.inserters.character-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6740)

*Returns*: out[.](#ostream.inserters.character-2.sentence-1)

[ð](#lib:operator%3c%3c,basic_ostream________)

`template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const charT* s);
template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const signed char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
                                          const unsigned char* s);
`

[3](#ostream.inserters.character-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6761)

*Preconditions*: s is not a null pointer[.](#ostream.inserters.character-3.sentence-1)

[4](#ostream.inserters.character-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6765)

*Effects*: Behaves like a formatted inserter (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements")) of out[.](#ostream.inserters.character-4.sentence-1)

Creates a character sequence seq of n characters
starting at s, each widened usingout.widen() ([[basic.ios.members]](basic.ios.members "31.5.4.3 Member functions")),
where n is the number that would be computed as if by:

- [(4.1)](#ostream.inserters.character-4.1)

traits​::​length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst charT*,
and also for the overload where the first argument is of typebasic_ostream<char, traits>& and the second is of typeconst char*,

- [(4.2)](#ostream.inserters.character-4.2)

char_traits<char>​::​length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst char*,

- [(4.3)](#ostream.inserters.character-4.3)

traits​::​length(reinterpret_cast<const char*>(s)) for the other two overloads[.](#ostream.inserters.character-4.sentence-2)

Determines padding for seq as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#ostream.inserters.character-4.sentence-3)

Inserts seq intoout[.](#ostream.inserters.character-4.sentence-4)

Calls width(0)[.](#ostream.inserters.character-4.sentence-5)

[5](#ostream.inserters.character-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6797)

*Returns*: out[.](#ostream.inserters.character-5.sentence-1)

#### [31.7.6.3.5](#ostream.formatted.print) Print [[ostream.formatted.print]](ostream.formatted.print)

[ð](#lib:print)

`template<class... Args>
  void print(ostream& os, format_string<Args...> fmt, Args&&... args);
`

[1](#ostream.formatted.print-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6811)

*Effects*: If the ordinary literal encoding ([[lex.charset]](lex.charset "5.3.1 Character sets")) is UTF-8, equivalent to:vprint_unicode(os, fmt.*str*, make_format_args(args...));

Otherwise, equivalent to:vprint_nonunicode(os, fmt.*str*, make_format_args(args...));

[ð](#lib:println)

`template<class... Args>
  void println(ostream& os, format_string<Args...> fmt, Args&&... args);
`

[2](#ostream.formatted.print-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6830)

*Effects*: Equivalent to:print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));

[ð](#lib:println_)

`void println(ostream& os);
`

[3](#ostream.formatted.print-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6844)

*Effects*: Equivalent to:print(os, "\n");

[ð](#lib:vprint_unicode)

`void vprint_unicode(ostream& os, string_view fmt, format_args args);
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
`

[4](#ostream.formatted.print-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6860)

*Effects*: Behaves as a formatted output function ([[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1 Common requirements"))
of os, except that:

- [(4.1)](#ostream.formatted.print-4.1)

failure to generate output is reported as specified below, and

- [(4.2)](#ostream.formatted.print-4.2)

any exception thrown by the call to vformat is propagated
without regard to the value of os.exceptions() and
without turning on ios_base​::​badbit in the error state of os[.](#ostream.formatted.print-4.sentence-1)

After constructing a sentry object,
the function initializes a variable with automatic storage duration viastring out = vformat(os.getloc(), fmt, args);

- [(4.3)](#ostream.formatted.print-4.3)

  If the function is vprint_unicode andos is a stream that refers to a terminal that
is capable of displaying Unicode only via a native Unicode API,
which is determined in an implementation-defined manner,
flushes os and then
writes out to the terminal using the native Unicode API;
if out contains invalid code units,the behavior is undefined[.](#ostream.formatted.print-4.3.sentence-1)
  Then establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2 Abstract machine"))[.](#ostream.formatted.print-4.3.sentence-2)

- [(4.4)](#ostream.formatted.print-4.4)

  Otherwise
inserts the character sequence
[out.begin(), out.end()) into os[.](#ostream.formatted.print-4.4.sentence-1)

If writing to the terminal or inserting into os fails,
calls os.setstate(ios_base​::​badbit) (which may throw ios_base​::​failure)[.](#ostream.formatted.print-4.sentence-3)

[5](#ostream.formatted.print-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6902)

*Recommended practice*: For vprint_unicode,
if invoking the native Unicode API requires transcoding,
implementations should substitute invalid code units
with U+fffd replacement character per
the Unicode Standard, Chapter 3.9 U+fffd Substitution in Conversion[.](#ostream.formatted.print-5.sentence-1)

#### [31.7.6.4](#ostream.unformatted) Unformatted output functions [[ostream.unformatted]](ostream.unformatted)

[1](#ostream.unformatted-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6913)

Each
unformatted
output function begins execution by constructing an object of classsentry[.](#ostream.unformatted-1.sentence-1)

If that object returnstrue,
while converting to a value of typebool,
the function endeavors
to generate the requested output[.](#ostream.unformatted-1.sentence-2)

If an exception is thrown during output, thenios_base​::​badbit is set[288](#footnote-288 "This is done without causing an ios_­base​::​failure to be thrown.") in*this's
error state[.](#ostream.unformatted-1.sentence-3)

If(exceptions() & badbit) != 0 then the exception is rethrown[.](#ostream.unformatted-1.sentence-4)

In any case, the unformatted output function ends by destroying thesentry object, then, if no exception was thrown, returning the value
specified for the unformatted output function[.](#ostream.unformatted-1.sentence-5)

[ð](#lib:put,basic_ostream)

`basic_ostream& put(char_type c);
`

[2](#ostream.unformatted-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6948)

*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-2.sentence-1)

After constructing a sentry object, inserts
the character c, if possible[.](#ostream.unformatted-2.sentence-2)[289](#footnote-289 "Note that this function is not overloaded on types signed char and unsigned char.")

[3](#ostream.unformatted-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6961)

Otherwise, callssetstate(badbit) (which may throwios_base​::​failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#ostream.unformatted-3.sentence-1)

[4](#ostream.unformatted-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6967)

*Returns*: *this[.](#ostream.unformatted-4.sentence-1)

[ð](#lib:write,basic_ostream)

`basic_ostream& write(const char_type* s, streamsize n);
`

[5](#ostream.unformatted-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6978)

*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-5.sentence-1)

After constructing a sentry object, obtains
characters to insert from
successive locations of an array whose first element is designated bys[.](#ostream.unformatted-5.sentence-2)[290](#footnote-290 "Note that this function is not overloaded on types signed char and unsigned char.")

Characters are inserted until either of the following occurs:

- [(5.1)](#ostream.unformatted-5.1)

n characters are inserted;

- [(5.2)](#ostream.unformatted-5.2)

inserting in the output sequence fails
(in which case the function callssetstate(badbit),
which may throwios_base​::​failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#ostream.unformatted-5.sentence-3)

[6](#ostream.unformatted-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7003)

*Returns*: *this[.](#ostream.unformatted-6.sentence-1)

[ð](#lib:flush,basic_ostream)

`basic_ostream& flush();
`

[7](#ostream.unformatted-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7014)

*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-7.sentence-1)

Ifrdbuf() is not a null pointer,
constructs a sentry object[.](#ostream.unformatted-7.sentence-2)

If that object returns true when converted to a value of type bool the function
callsrdbuf()->pubsync()[.](#ostream.unformatted-7.sentence-3)

If that function returns â1 callssetstate(badbit) (which may throwios_base​::​failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#ostream.unformatted-7.sentence-4)

Otherwise, if the sentry object returns false, does nothing[.](#ostream.unformatted-7.sentence-5)

[8](#ostream.unformatted-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7030)

*Returns*: *this[.](#ostream.unformatted-8.sentence-1)

[288)](#footnote-288)[288)](#footnoteref-288)

This is done without causing anios_base​::​failure to be thrown[.](#footnote-288.sentence-1)

[289)](#footnote-289)[289)](#footnoteref-289)

Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-289.sentence-1)

[290)](#footnote-290)[290)](#footnoteref-290)

Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-290.sentence-1)

#### [31.7.6.5](#ostream.manip) Standard basic_ostream manipulators [[ostream.manip]](ostream.manip)

[1](#ostream.manip-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7037)

Each instantiation of any of the function templates
specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1 Namespace std"))[.](#ostream.manip-1.sentence-1)

[ð](#lib:endl_)

`template<class charT, class traits>
  basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);
`

[2](#ostream.manip-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7049)

*Effects*: Callsos.put(os.widen('\n')),
thenos.flush()[.](#ostream.manip-2.sentence-1)

[3](#ostream.manip-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7056)

*Returns*: os[.](#ostream.manip-3.sentence-1)

[ð](#lib:ends)

`template<class charT, class traits>
  basic_ostream<charT, traits>& ends(basic_ostream<charT, traits>& os);
`

[4](#ostream.manip-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7068)

*Effects*: Inserts a null character into the output sequence:
callsos.put(charT())[.](#ostream.manip-4.sentence-1)

[5](#ostream.manip-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7074)

*Returns*: os[.](#ostream.manip-5.sentence-1)

[ð](#lib:flush_)

`template<class charT, class traits>
  basic_ostream<charT, traits>& flush(basic_ostream<charT, traits>& os);
`

[6](#ostream.manip-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7086)

*Effects*: Callsos.flush()[.](#ostream.manip-6.sentence-1)

[7](#ostream.manip-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7091)

*Returns*: os[.](#ostream.manip-7.sentence-1)

[ð](#lib:emit_on_flush)

`template<class charT, class traits>
  basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os);
`

[8](#ostream.manip-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7103)

*Effects*: If os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
calls buf->set_emit_on_sync(true)[.](#ostream.manip-8.sentence-1)

Otherwise this manipulator has no effect[.](#ostream.manip-8.sentence-2)

[*Note [1](#ostream.manip-note-1)*:

To work around the issue that theAllocator template argument cannot be deduced,
implementations can introduce an intermediate base class
to basic_syncbuf that manages its *emit-on-sync* flag[.](#ostream.manip-8.sentence-3)

â *end note*]

[9](#ostream.manip-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7117)

*Returns*: os[.](#ostream.manip-9.sentence-1)

[ð](#lib:noemit_on_flush)

`template<class charT, class traits>
  basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os);
`

[10](#ostream.manip-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7129)

*Effects*: If os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
calls buf->set_emit_on_sync(false)[.](#ostream.manip-10.sentence-1)

Otherwise this manipulator has no effect[.](#ostream.manip-10.sentence-2)

[11](#ostream.manip-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7137)

*Returns*: os[.](#ostream.manip-11.sentence-1)

[ð](#lib:flush_emit)

`template<class charT, class traits>
  basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os);
`

[12](#ostream.manip-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7149)

*Effects*: Calls os.flush()[.](#ostream.manip-12.sentence-1)

Then, if os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
behaves as an unformatted output function ([[ostream.unformatted]](#ostream.unformatted "31.7.6.4 Unformatted output functions"))
of os[.](#ostream.manip-12.sentence-2)

After constructing a sentry object, calls buf->emit()[.](#ostream.manip-12.sentence-3)

If that call returns false, calls os.setstate(ios_base​::​badbit)[.](#ostream.manip-12.sentence-4)

[13](#ostream.manip-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7160)

*Returns*: os[.](#ostream.manip-13.sentence-1)

#### [31.7.6.6](#ostream.rvalue) Rvalue stream insertion [[ostream.rvalue]](ostream.rvalue)

[ð](#lib:operator%3c%3c,basic_ostream_________)

`template<class Ostream, class T>
  Ostream&& operator<<(Ostream&& os, const T& x);
`

[1](#ostream.rvalue-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7174)

*Constraints*: The expression os << x is well-formed
when treated as an unevaluated operand andOstream is publicly and unambiguously derived from ios_base[.](#ostream.rvalue-1.sentence-1)

[2](#ostream.rvalue-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7180)

*Effects*: As if by: os << x;

[3](#ostream.rvalue-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7184)

*Returns*: std​::​move(os)[.](#ostream.rvalue-3.sentence-1)
