Files
cppdraft_translate/cppdraft/ostream/manip.md
2025-10-25 03:02:53 +03:00

153 lines
4.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.1Namespace 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.4Unformatted 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)