141 lines
4.9 KiB
Markdown
141 lines
4.9 KiB
Markdown
[ostream.inserters]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.inserters)
|
||
|
||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.inserters)
|
||
|
||
#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#ostream.inserters)
|
||
|
||
#### 31.7.6.3.3 basic_ostream::operator<< [ostream.inserters]
|
||
|
||
[ð](#lib:operator%3c%3c,basic_ostream)
|
||
|
||
`basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6581)
|
||
|
||
*Effects*: None[.](#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"))[.](#1.sentence-2)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6587)
|
||
|
||
*Returns*: pf(*this)[.](#2.sentence-1)[286](#footnote-286 "See, for example, the function signature endl(basic_ostream&) ([ostream.manip]).")
|
||
|
||
[ð](#lib:operator%3c%3c,basic_ostream_)
|
||
|
||
`basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6603)
|
||
|
||
*Effects*: Callspf(*this)[.](#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"))[.](#3.sentence-2)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6610)
|
||
|
||
*Returns*: *this[.](#4.sentence-1)[287](#footnote-287 "See, for example, the function signature dec(ios_base&) ([basefield.manip]).")
|
||
|
||
[ð](#lib:operator%3c%3c,basic_ostream__)
|
||
|
||
`basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
|
||
`
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6626)
|
||
|
||
*Effects*: Callspf(*this)[.](#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"))[.](#5.sentence-2)
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6633)
|
||
|
||
*Returns*: *this[.](#6.sentence-1)
|
||
|
||
[ð](#lib:operator%3c%3c,basic_ostream___)
|
||
|
||
`basic_ostream& operator<<(basic_streambuf<charT, traits>* sb);
|
||
`
|
||
|
||
[7](#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"))[.](#7.sentence-1)
|
||
|
||
After the sentry object is
|
||
constructed, ifsb is null callssetstate(badbit) (which may throwios_base::failure)[.](#7.sentence-2)
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6654)
|
||
|
||
Gets characters from sb and inserts them in*this[.](#8.sentence-1)
|
||
|
||
Characters are read from sb and inserted until any of the following occurs:
|
||
|
||
- [(8.1)](#8.1)
|
||
|
||
end-of-file occurs on the input sequence;
|
||
|
||
- [(8.2)](#8.2)
|
||
|
||
inserting in the output sequence fails
|
||
(in which case the character to be inserted is not extracted);
|
||
|
||
- [(8.3)](#8.3)
|
||
|
||
an exception occurs while getting a character from sb[.](#8.sentence-2)
|
||
|
||
[9](#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")))[.](#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[.](#9.sentence-2)
|
||
|
||
[10](#10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6684)
|
||
|
||
*Returns*: *this[.](#10.sentence-1)
|
||
|
||
[ð](#lib:operator%3c%3c,basic_ostream____)
|
||
|
||
`basic_ostream& operator<<(nullptr_t);
|
||
`
|
||
|
||
[11](#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]")[.](#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)
|