[ostream.manip]

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

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

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

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

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

[ð](#lib:endl)

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

[2](#2)

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

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

[3](#3)

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

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

[ð](#lib:ends)

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

[4](#4)

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

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

[5](#5)

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

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

[ð](#lib:flush)

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

[6](#6)

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

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

[7](#7)

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

*Returns*: os[.](#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](#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)[.](#8.sentence-1)

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

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

â *end note*]

[9](#9)

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

*Returns*: os[.](#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](#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)[.](#10.sentence-1)

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

[11](#11)

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

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

[ð](#lib:flush_emit)

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

[12](#12)

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

*Effects*: Calls os.flush()[.](#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[.](#12.sentence-2)

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

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

[13](#13)

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

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