Init
This commit is contained in:
39
cppdraft/ostream/assign.md
Normal file
39
cppdraft/ostream/assign.md
Normal file
@@ -0,0 +1,39 @@
|
||||
[ostream.assign]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.assign)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.assign)
|
||||
|
||||
#### 31.7.6.2 Class template basic_ostream [[ostream]](ostream#assign)
|
||||
|
||||
#### 31.7.6.2.3 Assignment and swap [ostream.assign]
|
||||
|
||||
[ð](#lib:operator=,basic_ostream)
|
||||
|
||||
`basic_ostream& operator=(basic_ostream&& rhs);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6164)
|
||||
|
||||
*Effects*: Equivalent to swap(rhs)[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6168)
|
||||
|
||||
*Returns*: *this[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:swap,basic_ostream)
|
||||
|
||||
`void swap(basic_ostream& rhs);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6179)
|
||||
|
||||
*Effects*: Calls basic_ios<charT, traits>::swap(rhs)[.](#3.sentence-1)
|
||||
53
cppdraft/ostream/cons.md
Normal file
53
cppdraft/ostream/cons.md
Normal file
@@ -0,0 +1,53 @@
|
||||
[ostream.cons]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.cons)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.cons)
|
||||
|
||||
#### 31.7.6.2 Class template basic_ostream [[ostream]](ostream#cons)
|
||||
|
||||
#### 31.7.6.2.2 Constructors [ostream.cons]
|
||||
|
||||
[ð](#lib:basic_ostream,constructor)
|
||||
|
||||
`explicit basic_ostream(basic_streambuf<charT, traits>* sb);
|
||||
`
|
||||
|
||||
[1](#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"))[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6125)
|
||||
|
||||
*Postconditions*: rdbuf() == sb[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:basic_ostream,constructor_)
|
||||
|
||||
`basic_ostream(basic_ostream&& rhs);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6136)
|
||||
|
||||
*Effects*: Move constructs from the rvalue rhs[.](#3.sentence-1)
|
||||
|
||||
This is accomplished by default constructing the base class and callingbasic_ios<charT, traits>::move(rhs) to initialize the
|
||||
base class[.](#3.sentence-2)
|
||||
|
||||
[ð](#lib:basic_ostream,destructor)
|
||||
|
||||
`virtual ~basic_ostream();
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6150)
|
||||
|
||||
*Remarks*: Does not perform any operations onrdbuf()[.](#4.sentence-1)
|
||||
497
cppdraft/ostream/formatted.md
Normal file
497
cppdraft/ostream/formatted.md
Normal file
@@ -0,0 +1,497 @@
|
||||
[ostream.formatted]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.formatted)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.formatted)
|
||||
|
||||
#### 31.7.6.3 Formatted output functions [ostream.formatted]
|
||||
|
||||
#### [31.7.6.3.1](#reqmts) Common requirements [[ostream.formatted.reqmts]](ostream.formatted.reqmts)
|
||||
|
||||
[1](#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[.](#reqmts-1.sentence-1)
|
||||
|
||||
If that object returnstrue when converted to a value of typebool,
|
||||
the function endeavors
|
||||
to generate the requested output[.](#reqmts-1.sentence-2)
|
||||
|
||||
If the generation fails, then the formatted output function doessetstate(ios_base::failbit),
|
||||
which can throw an exception[.](#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[.](#reqmts-1.sentence-4)
|
||||
|
||||
If(exceptions() & badbit) != 0 then the exception is rethrown[.](#reqmts-1.sentence-5)
|
||||
|
||||
Whether or not an exception is thrown, thesentry object is destroyed before leaving the formatted output function[.](#reqmts-1.sentence-6)
|
||||
|
||||
If no exception is thrown, the result of the formatted output function
|
||||
is*this[.](#reqmts-1.sentence-7)
|
||||
|
||||
[2](#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[.](#reqmts-2.sentence-1)
|
||||
|
||||
[3](#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[.](#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[.](#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[.](#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]](#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&) ([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]](#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&) ([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]](#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](#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]](#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]](#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]](#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](#print) Print [[ostream.formatted.print]](ostream.formatted.print)
|
||||
|
||||
[ð](#lib:print)
|
||||
|
||||
`template<class... Args>
|
||||
void print(ostream& os, format_string<Args...> fmt, Args&&... args);
|
||||
`
|
||||
|
||||
[1](#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](#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](#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](#print-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6860)
|
||||
|
||||
*Effects*: Behaves as a formatted output function ([[ostream.formatted.reqmts]](#reqmts "31.7.6.3.1 Common requirements"))
|
||||
of os, except that:
|
||||
|
||||
- [(4.1)](#print-4.1)
|
||||
|
||||
failure to generate output is reported as specified below, and
|
||||
|
||||
- [(4.2)](#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[.](#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)](#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[.](#print-4.3.sentence-1)
|
||||
Then establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2 Abstract machine"))[.](#print-4.3.sentence-2)
|
||||
|
||||
- [(4.4)](#print-4.4)
|
||||
|
||||
Otherwise
|
||||
inserts the character sequence
|
||||
[out.begin(), out.end()) into os[.](#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)[.](#print-4.sentence-3)
|
||||
|
||||
[5](#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[.](#print-5.sentence-1)
|
||||
103
cppdraft/ostream/formatted/print.md
Normal file
103
cppdraft/ostream/formatted/print.md
Normal file
@@ -0,0 +1,103 @@
|
||||
[ostream.formatted.print]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.formatted.print)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.formatted.print)
|
||||
|
||||
#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#print)
|
||||
|
||||
#### 31.7.6.3.5 Print [ostream.formatted.print]
|
||||
|
||||
[ð](#lib:print)
|
||||
|
||||
`template<class... Args>
|
||||
void print(ostream& os, format_string<Args...> fmt, Args&&... args);
|
||||
`
|
||||
|
||||
[1](#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](#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](#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](#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)](#4.1)
|
||||
|
||||
failure to generate output is reported as specified below, and
|
||||
|
||||
- [(4.2)](#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[.](#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)](#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[.](#4.3.sentence-1)
|
||||
Then establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2 Abstract machine"))[.](#4.3.sentence-2)
|
||||
|
||||
- [(4.4)](#4.4)
|
||||
|
||||
Otherwise
|
||||
inserts the character sequence
|
||||
[out.begin(), out.end()) into os[.](#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)[.](#4.sentence-3)
|
||||
|
||||
[5](#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[.](#5.sentence-1)
|
||||
62
cppdraft/ostream/formatted/reqmts.md
Normal file
62
cppdraft/ostream/formatted/reqmts.md
Normal file
@@ -0,0 +1,62 @@
|
||||
[ostream.formatted.reqmts]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.formatted.reqmts)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.formatted.reqmts)
|
||||
|
||||
#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#reqmts)
|
||||
|
||||
#### 31.7.6.3.1 Common requirements [ostream.formatted.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6354)
|
||||
|
||||
Each formatted output function begins execution by constructing an object of classsentry[.](#1.sentence-1)
|
||||
|
||||
If that object returnstrue when converted to a value of typebool,
|
||||
the function endeavors
|
||||
to generate the requested output[.](#1.sentence-2)
|
||||
|
||||
If the generation fails, then the formatted output function doessetstate(ios_base::failbit),
|
||||
which can throw an exception[.](#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[.](#1.sentence-4)
|
||||
|
||||
If(exceptions() & badbit) != 0 then the exception is rethrown[.](#1.sentence-5)
|
||||
|
||||
Whether or not an exception is thrown, thesentry object is destroyed before leaving the formatted output function[.](#1.sentence-6)
|
||||
|
||||
If no exception is thrown, the result of the formatted output function
|
||||
is*this[.](#1.sentence-7)
|
||||
|
||||
[2](#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[.](#2.sentence-1)
|
||||
|
||||
[3](#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[.](#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[.](#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[.](#3.sentence-3)
|
||||
|
||||
[285)](#footnote-285)[285)](#footnoteref-285)
|
||||
|
||||
This is done without causing anios_base::failure to be thrown[.](#footnote-285.sentence-1)
|
||||
95
cppdraft/ostream/general.md
Normal file
95
cppdraft/ostream/general.md
Normal file
@@ -0,0 +1,95 @@
|
||||
[ostream.general]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.general)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.general)
|
||||
|
||||
#### 31.7.6.2 Class template basic_ostream [[ostream]](ostream#general)
|
||||
|
||||
#### 31.7.6.2.1 General [ostream.general]
|
||||
|
||||
[1](#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"))[.](#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](#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[.](#2.sentence-1)
|
||||
|
||||
[3](#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)[.](#3.sentence-1)
|
||||
|
||||
They may use other public members ofbasic_ostream except that they shall not invoke any virtual members ofrdbuf() exceptoverflow(),xsputn(),
|
||||
andsync()[.](#3.sentence-2)
|
||||
|
||||
[4](#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[.](#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[.](#4.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6105)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The deleted overloads of operator<< prevent formatting characters as integers and strings as pointers[.](#5.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
140
cppdraft/ostream/inserters.md
Normal file
140
cppdraft/ostream/inserters.md
Normal file
@@ -0,0 +1,140 @@
|
||||
[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)
|
||||
119
cppdraft/ostream/inserters/arithmetic.md
Normal file
119
cppdraft/ostream/inserters/arithmetic.md
Normal file
@@ -0,0 +1,119 @@
|
||||
[ostream.inserters.arithmetic]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.inserters.arithmetic)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.inserters.arithmetic)
|
||||
|
||||
#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#ostream.inserters.arithmetic)
|
||||
|
||||
#### 31.7.6.3.2 Arithmetic inserters [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](#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[.](#1.sentence-1)
|
||||
|
||||
These inserter functions use the imbuedlocale value to perform numeric formatting[.](#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](#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<>[.](#2.sentence-1)
|
||||
|
||||
It bypassesostreams
|
||||
and usesstreambufs
|
||||
directly[.](#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[.](#2.sentence-3)
|
||||
|
||||
The second parameter is a reference to the base class subobject of typeios_base[.](#2.sentence-4)
|
||||
|
||||
It provides formatting specifications such as field width, and
|
||||
a locale from which to obtain other facets[.](#2.sentence-5)
|
||||
|
||||
Iffailed istrue then doessetstate(badbit),
|
||||
which may throw an exception, and returns[.](#2.sentence-6)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6523)
|
||||
|
||||
*Returns*: *this[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c%3c,basic_ostream_)
|
||||
|
||||
`basic_ostream& operator<<(const volatile void* p);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6534)
|
||||
|
||||
*Effects*: Equivalent to: return operator<<(const_cast<const void*>(p));
|
||||
|
||||
[ð](#itemdecl:3)
|
||||
|
||||
`basic_ostream& operator<<(extended-floating-point-type val);
|
||||
`
|
||||
|
||||
[5](#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[.](#5.sentence-3)
|
||||
|
||||
If failed is true then does setstate(badbit),
|
||||
which may throw an exception, and returns[.](#5.sentence-4)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6568)
|
||||
|
||||
*Returns*: *this[.](#6.sentence-1)
|
||||
109
cppdraft/ostream/inserters/character.md
Normal file
109
cppdraft/ostream/inserters/character.md
Normal file
@@ -0,0 +1,109 @@
|
||||
[ostream.inserters.character]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.inserters.character)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.inserters.character)
|
||||
|
||||
#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#ostream.inserters.character)
|
||||
|
||||
#### 31.7.6.3.4 Character inserter function templates [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](#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[.](#1.sentence-1)
|
||||
|
||||
Constructs a character sequence seq[.](#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[.](#1.sentence-3)
|
||||
|
||||
Determines padding for seq as described
|
||||
in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#1.sentence-4)
|
||||
|
||||
Inserts seq intoout[.](#1.sentence-5)
|
||||
|
||||
Calls os.width(0)[.](#1.sentence-6)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6740)
|
||||
|
||||
*Returns*: out[.](#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](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6761)
|
||||
|
||||
*Preconditions*: s is not a null pointer[.](#3.sentence-1)
|
||||
|
||||
[4](#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[.](#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)](#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)](#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)](#4.3)
|
||||
|
||||
traits::length(reinterpret_cast<const char*>(s)) for the other two overloads[.](#4.sentence-2)
|
||||
|
||||
Determines padding for seq as described
|
||||
in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#4.sentence-3)
|
||||
|
||||
Inserts seq intoout[.](#4.sentence-4)
|
||||
|
||||
Calls width(0)[.](#4.sentence-5)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6797)
|
||||
|
||||
*Returns*: out[.](#5.sentence-1)
|
||||
91
cppdraft/ostream/iterator.md
Normal file
91
cppdraft/ostream/iterator.md
Normal file
@@ -0,0 +1,91 @@
|
||||
[ostream.iterator]
|
||||
|
||||
# 24 Iterators library [[iterators]](./#iterators)
|
||||
|
||||
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#ostream.iterator)
|
||||
|
||||
### 24.6.3 Class template ostream_iterator [ostream.iterator]
|
||||
|
||||
#### [24.6.3.1](#general) General [[ostream.iterator.general]](ostream.iterator.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6725)
|
||||
|
||||
ostream_iterator writes (usingoperator<<)
|
||||
successive elements onto the output stream from which it was constructed[.](#general-1.sentence-1)
|
||||
|
||||
If it was constructed withcharT* as a constructor argument, this string, called a[*delimiter string*](#def:delimiter_string),
|
||||
is written to the stream after everyT is written[.](#general-1.sentence-2)
|
||||
|
||||
namespace std {template<class T, class charT = char, class traits = char_traits<charT>>class ostream_iterator {public:using iterator_category = output_iterator_tag; using value_type = void; using difference_type = ptrdiff_t; using pointer = void; using reference = void; using char_type = charT; using traits_type = traits; using ostream_type = basic_ostream<charT,traits>;
|
||||
|
||||
ostream_iterator(ostream_type& s);
|
||||
ostream_iterator(ostream_type& s, const charT* delimiter);
|
||||
ostream_iterator(const ostream_iterator& x); ~ostream_iterator();
|
||||
ostream_iterator& operator=(const ostream_iterator&) = default;
|
||||
ostream_iterator& operator=(const T& value);
|
||||
|
||||
ostream_iterator& operator*();
|
||||
ostream_iterator& operator++();
|
||||
ostream_iterator& operator++(int); private: basic_ostream<charT,traits>* out_stream; // *exposition only*const charT* delim; // *exposition only*};}
|
||||
|
||||
#### [24.6.3.2](#cons.des) Constructors and destructor [[ostream.iterator.cons.des]](ostream.iterator.cons.des)
|
||||
|
||||
[ð](#lib:ostream_iterator,constructor)
|
||||
|
||||
`ostream_iterator(ostream_type& s);
|
||||
`
|
||||
|
||||
[1](#cons.des-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6779)
|
||||
|
||||
*Effects*: Initializes out_stream with addressof(s) anddelim with nullptr[.](#cons.des-1.sentence-1)
|
||||
|
||||
[ð](#lib:ostream_iterator,constructor_)
|
||||
|
||||
`ostream_iterator(ostream_type& s, const charT* delimiter);
|
||||
`
|
||||
|
||||
[2](#cons.des-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6792)
|
||||
|
||||
*Effects*: Initializes out_stream with addressof(s) anddelim with delimiter[.](#cons.des-2.sentence-1)
|
||||
|
||||
#### [24.6.3.3](#ops) Operations [[ostream.iterator.ops]](ostream.iterator.ops)
|
||||
|
||||
[ð](#lib:operator=,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator=(const T& value);
|
||||
`
|
||||
|
||||
[1](#ops-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6806)
|
||||
|
||||
*Effects*: As if by:*out_stream << value;if (delim)*out_stream << delim;return *this;
|
||||
|
||||
[ð](#lib:operator*,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator*();
|
||||
`
|
||||
|
||||
[2](#ops-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6823)
|
||||
|
||||
*Returns*: *this[.](#ops-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator++,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator++();
|
||||
ostream_iterator& operator++(int);
|
||||
`
|
||||
|
||||
[3](#ops-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6835)
|
||||
|
||||
*Returns*: *this[.](#ops-3.sentence-1)
|
||||
31
cppdraft/ostream/iterator/cons/des.md
Normal file
31
cppdraft/ostream/iterator/cons/des.md
Normal file
@@ -0,0 +1,31 @@
|
||||
[ostream.iterator.cons.des]
|
||||
|
||||
# 24 Iterators library [[iterators]](./#iterators)
|
||||
|
||||
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#ostream.iterator.cons.des)
|
||||
|
||||
### 24.6.3 Class template ostream_iterator [[ostream.iterator]](ostream.iterator#cons.des)
|
||||
|
||||
#### 24.6.3.2 Constructors and destructor [ostream.iterator.cons.des]
|
||||
|
||||
[ð](#lib:ostream_iterator,constructor)
|
||||
|
||||
`ostream_iterator(ostream_type& s);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6779)
|
||||
|
||||
*Effects*: Initializes out_stream with addressof(s) anddelim with nullptr[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:ostream_iterator,constructor_)
|
||||
|
||||
`ostream_iterator(ostream_type& s, const charT* delimiter);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6792)
|
||||
|
||||
*Effects*: Initializes out_stream with addressof(s) anddelim with delimiter[.](#2.sentence-1)
|
||||
31
cppdraft/ostream/iterator/general.md
Normal file
31
cppdraft/ostream/iterator/general.md
Normal file
@@ -0,0 +1,31 @@
|
||||
[ostream.iterator.general]
|
||||
|
||||
# 24 Iterators library [[iterators]](./#iterators)
|
||||
|
||||
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#ostream.iterator.general)
|
||||
|
||||
### 24.6.3 Class template ostream_iterator [[ostream.iterator]](ostream.iterator#general)
|
||||
|
||||
#### 24.6.3.1 General [ostream.iterator.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6725)
|
||||
|
||||
ostream_iterator writes (usingoperator<<)
|
||||
successive elements onto the output stream from which it was constructed[.](#1.sentence-1)
|
||||
|
||||
If it was constructed withcharT* as a constructor argument, this string, called a[*delimiter string*](#def:delimiter_string),
|
||||
is written to the stream after everyT is written[.](#1.sentence-2)
|
||||
|
||||
namespace std {template<class T, class charT = char, class traits = char_traits<charT>>class ostream_iterator {public:using iterator_category = output_iterator_tag; using value_type = void; using difference_type = ptrdiff_t; using pointer = void; using reference = void; using char_type = charT; using traits_type = traits; using ostream_type = basic_ostream<charT,traits>;
|
||||
|
||||
ostream_iterator(ostream_type& s);
|
||||
ostream_iterator(ostream_type& s, const charT* delimiter);
|
||||
ostream_iterator(const ostream_iterator& x); ~ostream_iterator();
|
||||
ostream_iterator& operator=(const ostream_iterator&) = default;
|
||||
ostream_iterator& operator=(const T& value);
|
||||
|
||||
ostream_iterator& operator*();
|
||||
ostream_iterator& operator++();
|
||||
ostream_iterator& operator++(int); private: basic_ostream<charT,traits>* out_stream; // *exposition only*const charT* delim; // *exposition only*};}
|
||||
43
cppdraft/ostream/iterator/ops.md
Normal file
43
cppdraft/ostream/iterator/ops.md
Normal file
@@ -0,0 +1,43 @@
|
||||
[ostream.iterator.ops]
|
||||
|
||||
# 24 Iterators library [[iterators]](./#iterators)
|
||||
|
||||
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#ostream.iterator.ops)
|
||||
|
||||
### 24.6.3 Class template ostream_iterator [[ostream.iterator]](ostream.iterator#ops)
|
||||
|
||||
#### 24.6.3.3 Operations [ostream.iterator.ops]
|
||||
|
||||
[ð](#lib:operator=,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator=(const T& value);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6806)
|
||||
|
||||
*Effects*: As if by:*out_stream << value;if (delim)*out_stream << delim;return *this;
|
||||
|
||||
[ð](#lib:operator*,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator*();
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6823)
|
||||
|
||||
*Returns*: *this[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:operator++,ostream_iterator)
|
||||
|
||||
`ostream_iterator& operator++();
|
||||
ostream_iterator& operator++(int);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6835)
|
||||
|
||||
*Returns*: *this[.](#3.sentence-1)
|
||||
152
cppdraft/ostream/manip.md
Normal file
152
cppdraft/ostream/manip.md
Normal file
@@ -0,0 +1,152 @@
|
||||
[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)
|
||||
34
cppdraft/ostream/rvalue.md
Normal file
34
cppdraft/ostream/rvalue.md
Normal file
@@ -0,0 +1,34 @@
|
||||
[ostream.rvalue]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.rvalue)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.rvalue)
|
||||
|
||||
#### 31.7.6.6 Rvalue stream insertion [ostream.rvalue]
|
||||
|
||||
[ð](#lib:operator%3c%3c,basic_ostream)
|
||||
|
||||
`template<class Ostream, class T>
|
||||
Ostream&& operator<<(Ostream&& os, const T& x);
|
||||
`
|
||||
|
||||
[1](#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[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7180)
|
||||
|
||||
*Effects*: As if by: os << x;
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7184)
|
||||
|
||||
*Returns*: std::move(os)[.](#3.sentence-1)
|
||||
73
cppdraft/ostream/seeks.md
Normal file
73
cppdraft/ostream/seeks.md
Normal file
@@ -0,0 +1,73 @@
|
||||
[ostream.seeks]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.seeks)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.seeks)
|
||||
|
||||
#### 31.7.6.2 Class template basic_ostream [[ostream]](ostream#seeks)
|
||||
|
||||
#### 31.7.6.2.5 Seek members [ostream.seeks]
|
||||
|
||||
[1](#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[.](#1.sentence-1)
|
||||
|
||||
It returns by destroying the sentry object[.](#1.sentence-2)
|
||||
|
||||
[ð](#lib:tellp,basic_ostream)
|
||||
|
||||
`pos_type tellp();
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6297)
|
||||
|
||||
*Returns*: Iffail() != false,
|
||||
returnspos_type(-1) to indicate failure[.](#2.sentence-1)
|
||||
|
||||
Otherwise, returnsrdbuf()->pubseekoff(0, cur, out)[.](#2.sentence-2)
|
||||
|
||||
[ð](#lib:seekp,basic_ostream)
|
||||
|
||||
`basic_ostream& seekp(pos_type pos);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6314)
|
||||
|
||||
*Effects*: Iffail() != true,
|
||||
executesrdbuf()->pubseekpos(pos, ios_base::out)[.](#3.sentence-1)
|
||||
|
||||
In case of failure, the function callssetstate(failbit) (which may throwios_base::failure)[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6325)
|
||||
|
||||
*Returns*: *this[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:seekp,basic_ostream_)
|
||||
|
||||
`basic_ostream& seekp(off_type off, ios_base::seekdir dir);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6336)
|
||||
|
||||
*Effects*: Iffail() != true,
|
||||
executesrdbuf()->pubseekoff(off, dir, ios_base::out)[.](#5.sentence-1)
|
||||
|
||||
In case of failure, the function calls setstate(failbit) (which may throw ios_base::failure)[.](#5.sentence-2)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6345)
|
||||
|
||||
*Returns*: *this[.](#6.sentence-1)
|
||||
80
cppdraft/ostream/sentry.md
Normal file
80
cppdraft/ostream/sentry.md
Normal file
@@ -0,0 +1,80 @@
|
||||
[ostream.sentry]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.sentry)
|
||||
|
||||
### 31.7.6 Output streams [[output.streams]](output.streams#ostream.sentry)
|
||||
|
||||
#### 31.7.6.2 Class template basic_ostream [[ostream]](ostream#sentry)
|
||||
|
||||
#### 31.7.6.2.4 Class basic_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](#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[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_ostream::sentry,constructor)
|
||||
|
||||
`explicit sentry(basic_ostream& os);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6217)
|
||||
|
||||
Ifos.good() is nonzero, prepares for formatted or unformatted output[.](#2.sentence-1)
|
||||
|
||||
Ifos.tie() is not a null pointer, callsos.tie()->flush()[.](#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](#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[.](#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")))[.](#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](#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()[.](#4.sentence-1)
|
||||
|
||||
If that function returns â1 or
|
||||
exits via an exception, sets badbit inos.rdstate() without propagating an exception[.](#4.sentence-2)
|
||||
|
||||
[ð](#lib:operator_bool,basic_ostream::sentry)
|
||||
|
||||
`explicit operator bool() const;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6279)
|
||||
|
||||
*Effects*: Returns*ok_*[.](#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)
|
||||
11
cppdraft/ostream/syn.md
Normal file
11
cppdraft/ostream/syn.md
Normal file
@@ -0,0 +1,11 @@
|
||||
[ostream.syn]
|
||||
|
||||
# 31 Input/output library [[input.output]](./#input.output)
|
||||
|
||||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.syn)
|
||||
|
||||
### 31.7.2 Header <ostream> synopsis [ostream.syn]
|
||||
|
||||
[ð](#header:%3costream%3e)
|
||||
|
||||
namespace std {// [[ostream]](ostream "31.7.6.2 Class template basic_ostream"), class template basic_ostreamtemplate<class charT, class traits = char_traits<charT>>class basic_ostream; using ostream = basic_ostream<char>; using wostream = basic_ostream<wchar_t>; // [[ostream.manip]](ostream.manip "31.7.6.5 Standard basic_ostream manipulators"), standard basic_ostream manipulatorstemplate<class charT, class traits> basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& ends(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os); // [[ostream.rvalue]](ostream.rvalue "31.7.6.6 Rvalue stream insertion"), rvalue stream insertiontemplate<class Ostream, class T> Ostream&& operator<<(Ostream&& os, const T& x); // [[ostream.formatted.print]](ostream.formatted.print "31.7.6.3.5 Print"), print functionstemplate<class... Args>void print(ostream& os, format_string<Args...> fmt, Args&&... args); template<class... Args>void println(ostream& os, format_string<Args...> fmt, Args&&... args); void println(ostream& os); void vprint_unicode(ostream& os, string_view fmt, format_args args); void vprint_nonunicode(ostream& os, string_view fmt, format_args args);}
|
||||
128
cppdraft/ostream/unformatted.md
Normal file
128
cppdraft/ostream/unformatted.md
Normal file
@@ -0,0 +1,128 @@
|
||||
[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)
|
||||
Reference in New Issue
Block a user