[ostream.unformatted]

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

## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.unformatted)

### 31.7.6 Output streams [[output.streams]](output.streams#ostream.unformatted)

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

[1](#1)

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

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

If that object returnstrue,
while converting to a value of typebool,
the function endeavors
to generate the requested output[.](#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[.](#1.sentence-3)

If(exceptions() & badbit) != 0 then the exception is rethrown[.](#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[.](#1.sentence-5)

[ð](#lib:put,basic_ostream)

`basic_ostream& put(char_type c);
`

[2](#2)

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

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

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

[3](#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")))[.](#3.sentence-1)

[4](#4)

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

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

[ð](#lib:write,basic_ostream)

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

[5](#5)

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

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

After constructing a sentry object, obtains
characters to insert from
successive locations of an array whose first element is designated bys[.](#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)](#5.1)

n characters are inserted;

- [(5.2)](#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")))[.](#5.sentence-3)

[6](#6)

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

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

[ð](#lib:flush,basic_ostream)

`basic_ostream& flush();
`

[7](#7)

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

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

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

If that object returns true when converted to a value of type bool the function
callsrdbuf()->pubsync()[.](#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")))[.](#7.sentence-4)

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

[8](#8)

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

*Returns*: *this[.](#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)
