This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
[istream.assign]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.assign)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.assign)
#### 31.7.5.2 Class template basic_istream [[istream]](istream#assign)
#### 31.7.5.2.3 Assignment and swap [istream.assign]
[🔗](#lib:operator=,basic_istream)
`basic_istream& operator=(basic_istream&& rhs);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4479)
*Effects*: Equivalent to swap(rhs)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4483)
*Returns*: *this[.](#2.sentence-1)
[🔗](#lib:swap,basic_istream)
`void swap(basic_istream& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4494)
*Effects*: Calls basic_ios<charT, traits>::swap(rhs)[.](#3.sentence-1)
Exchanges the values returned by gcount() andrhs.gcount()[.](#3.sentence-2)

51
cppdraft/istream/cons.md Normal file
View File

@@ -0,0 +1,51 @@
[istream.cons]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.cons)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.cons)
#### 31.7.5.2 Class template basic_istream [[istream]](istream#cons)
#### 31.7.5.2.2 Constructors [istream.cons]
[🔗](#lib:basic_istream,constructor)
`explicit basic_istream(basic_streambuf<charT, traits>* sb);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4434)
*Effects*: Initializes the base class subobject withbasic_ios::init(sb) ([[basic.ios.cons]](basic.ios.cons "31.5.4.2Constructors"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4439)
*Postconditions*: gcount() == 0[.](#2.sentence-1)
[🔗](#lib:basic_istream,constructor_)
`basic_istream(basic_istream&& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4451)
*Effects*: Default constructs the base class, copies thegcount() from rhs, callsbasic_ios<charT, traits>::move(rhs) to initialize the base
class, and sets the gcount() for rhs to 0[.](#3.sentence-1)
[🔗](#lib:basic_istream,destructor)
`virtual ~basic_istream();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4465)
*Remarks*: Does not perform any operations ofrdbuf()[.](#4.sentence-1)

View File

@@ -0,0 +1,221 @@
[istream.extractors]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.extractors)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.extractors)
#### 31.7.5.3 Formatted input functions [[istream.formatted]](istream.formatted#istream.extractors)
#### 31.7.5.3.3 basic_istream::operator>> [istream.extractors]
[🔗](#lib:operator%3e%3e,basic_istream)
`basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4857)
*Effects*: None[.](#1.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4863)
*Returns*: pf(*this)[.](#2.sentence-1)
[274](#footnote-274 "See, for example, the function signature ws(basic_­istream&amp;) ([istream.manip]).")
[🔗](#lib:operator%3e%3e,basic_istream_)
`basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4879)
*Effects*: Callspf(*this)[.](#3.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4886)
*Returns*: *this[.](#4.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream__)
`basic_istream& operator>>(ios_base& (*pf)(ios_base&));
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4897)
*Effects*: Callspf(*this)[.](#5.sentence-1)[275](#footnote-275 "See, for example, the function signature dec(ios_­base&amp;) ([basefield.manip]).")
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#5.sentence-2)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4908)
*Returns*: *this[.](#6.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream___)
`template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char (&s)[N]);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4924)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))
of in[.](#7.sentence-1)
After asentry object is constructed,operator>> extracts characters and stores them intos[.](#7.sentence-2)
Ifwidth() is greater than zero, n ismin(size_t(width()), N)[.](#7.sentence-3)
Otherwise n is N[.](#7.sentence-4)
n is the maximum number of characters stored[.](#7.sentence-5)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4941)
Characters are extracted and stored until any of the following occurs:
- [(8.1)](#8.1)
n - 1 characters are stored;
- [(8.2)](#8.2)
end of file occurs on the input sequence;
- [(8.3)](#8.3)
letting ct be use_facet<ctype<charT>>(in.getloc()),ct.is(ct.space, c) is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4950)
operator>> then stores a null byte
(charT())
in the next position, which may be the first position if no characters
were extracted[.](#9.sentence-1)
operator>> then callswidth(0)[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4960)
If the function extracted no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4965)
*Returns*: in[.](#11.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream____)
`template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4981)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))
of in[.](#12.sentence-1)
A character is extracted from in, if one is available, and stored in c[.](#12.sentence-2)
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#12.sentence-3)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4990)
*Returns*: in[.](#13.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream_____)
`basic_istream& operator>>(basic_streambuf<charT, traits>* sb);
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5001)
*Effects*: Behaves as an [unformatted input function](istream.unformatted "31.7.5.4Unformatted input functions[istream.unformatted]")[.](#14.sentence-1)
If sb is null, callssetstate(failbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))[.](#14.sentence-2)
After a sentry object is constructed, extracts
characters from*this and inserts them in the output sequence controlled by sb[.](#14.sentence-3)
Characters are extracted and inserted until any of the following occurs:
- [(14.1)](#14.1)
end-of-file occurs on the input sequence;
- [(14.2)](#14.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(14.3)](#14.3)
an exception occurs (in which case the exception is caught)[.](#14.sentence-4)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5023)
If the function inserts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5028)
*Returns*: *this[.](#16.sentence-1)
[274)](#footnote-274)[274)](#footnoteref-274)
See, for example, the function signaturews(basic_istream&) ([[istream.manip]](istream.manip "31.7.5.5Standard basic_­istream manipulators"))[.](#footnote-274.sentence-1)
[275)](#footnote-275)[275)](#footnoteref-275)
See, for example, the function signaturedec(ios_base&) ([[basefield.manip]](basefield.manip "31.5.5.3basefield manipulators"))[.](#footnote-275.sentence-1)

View File

@@ -0,0 +1,392 @@
[istream.formatted]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.formatted)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.formatted)
#### 31.7.5.3 Formatted input functions [istream.formatted]
#### [31.7.5.3.1](#reqmts) Common requirements [[istream.formatted.reqmts]](istream.formatted.reqmts)
[1](#reqmts-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4655)
Each formatted input function begins execution by constructing
an object of type ios_base::iostate, termed the local error state, and
initializing it to ios_base::goodbit[.](#reqmts-1.sentence-1)
It then creates an object of classsentry with thenoskipws (second) argumentfalse[.](#reqmts-1.sentence-2)
If thesentry object returnstrue,
when converted to a value of typebool,
the function endeavors
to obtain the requested input[.](#reqmts-1.sentence-3)
Otherwise,
if the sentry constructor exits by throwing an exception or
if the sentry object produces false when converted to a value of type bool,
the function returns without attempting to obtain any input[.](#reqmts-1.sentence-4)
If rdbuf()->sbumpc() or rdbuf()->sgetc() returns traits::eof(), thenios_base::eofbit is set in the local error state and
the input function stops trying to obtain the requested input[.](#reqmts-1.sentence-5)
If an exception is thrown during input thenios_base::badbit is set in the local error state,*this's error state is set to the local error state, and
the exception is rethrown if (exceptions() & badbit) != 0[.](#reqmts-1.sentence-6)
After extraction is done, the input function calls setstate, which
sets *this's error state to the local error state, and
may throw an exception[.](#reqmts-1.sentence-7)
In any case, the formatted input function destroys thesentry object[.](#reqmts-1.sentence-8)
If no exception has been thrown, it returns*this[.](#reqmts-1.sentence-9)
#### [31.7.5.3.2](#arithmetic) Arithmetic extractors [[istream.formatted.arithmetic]](istream.formatted.arithmetic)
[🔗](#lib:operator%3e%3e,basic_istream)
`basic_istream& operator>>(unsigned short& val);
basic_istream& operator>>(unsigned int& val);
basic_istream& operator>>(long& val);
basic_istream& operator>>(unsigned long& val);
basic_istream& operator>>(long long& val);
basic_istream& operator>>(unsigned long long& val);
basic_istream& operator>>(float& val);
basic_istream& operator>>(double& val);
basic_istream& operator>>(long double& val);
basic_istream& operator>>(bool& val);
basic_istream& operator>>(void*& val);
`
[1](#arithmetic-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4713)
As in the case of the inserters, these extractors depend on the
locale's[num_get<>](locale.num.get "28.3.4.3.2Class template num_­get[locale.num.get]") object to perform parsing the input
stream data[.](#arithmetic-1.sentence-1)
These extractors behave as formatted input functions (as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))[.](#arithmetic-1.sentence-2)
After a sentry object is constructed, the
conversion occurs as if performed by the following code fragment,
where state represents the input function's local error state:using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
use_facet<numget>(loc).get(*this, 0, *this, state, val);
In the above fragment,loc stands for the private member of thebasic_ios class[.](#arithmetic-1.sentence-4)
[*Note [1](#arithmetic-note-1)*:
The first argument provides an object of theistreambuf_iterator class which is an iterator pointed to an input stream[.](#arithmetic-1.sentence-5)
It bypasses istreams and uses streambufs directly[.](#arithmetic-1.sentence-6)
— *end note*]
Classlocale relies on this
type as its interface toistream,
so that it does not need to depend directly onistream[.](#arithmetic-1.sentence-7)
[🔗](#lib:operator%3e%3e,basic_istream_)
`basic_istream& operator>>(short& val);
`
[2](#arithmetic-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4751)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<short>::min()) { state |= ios_base::failbit;
val = numeric_limits<short>::min();} else if (numeric_limits<short>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<short>::max();} else val = static_cast<short>(lval);
[🔗](#lib:operator%3e%3e,basic_istream__)
`basic_istream& operator>>(int& val);
`
[3](#arithmetic-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4775)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<int>::min()) { state |= ios_base::failbit;
val = numeric_limits<int>::min();} else if (numeric_limits<int>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<int>::max();} else val = static_cast<int>(lval);
[🔗](#arithmetic-itemdecl:4)
`basic_istream& operator>>(extended-floating-point-type& val);
`
[4](#arithmetic-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4798)
If
the floating-point conversion rank of *extended-floating-point-type* is not less than or equal to that of long double,
then an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#arithmetic-4.sentence-1)
[5](#arithmetic-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4806)
Otherwise, let FP be a standard floating-point type:
- [(5.1)](#arithmetic-5.1)
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of float,
then FP is float,
- [(5.2)](#arithmetic-5.2)
otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
then FP is double,
- [(5.3)](#arithmetic-5.3)
otherwise, FP is long double[.](#arithmetic-5.sentence-1)
[6](#arithmetic-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4822)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
FP fval;
use_facet<numget>(loc).get(*this, 0, *this, state, fval);if (fval < -numeric_limits<*extended-floating-point-type*>::max()) { state |= ios_base::failbit;
val = -numeric_limits<*extended-floating-point-type*>::max();} else if (numeric_limits<*extended-floating-point-type*>::max() < fval) { state |= ios_base::failbit;
val = numeric_limits<*extended-floating-point-type*>::max();} else { val = static_cast<*extended-floating-point-type*>(fval);}
[*Note [2](#arithmetic-note-2)*:
When the extended floating-point type has
a floating-point conversion rank
that is not equal to the rank of any standard floating-point type,
then double rounding during the conversion can result in inaccurate results[.](#arithmetic-6.sentence-1)
from_chars can be used in situations
where maximum accuracy is important[.](#arithmetic-6.sentence-2)
— *end note*]
#### [31.7.5.3.3](#istream.extractors) basic_istream::operator>> [[istream.extractors]](istream.extractors)
[🔗](#lib:operator%3e%3e,basic_istream___)
`basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
`
[1](#istream.extractors-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4857)
*Effects*: None[.](#istream.extractors-1.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-1.sentence-2)
[2](#istream.extractors-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4863)
*Returns*: pf(*this)[.](#istream.extractors-2.sentence-1)
[274](#footnote-274 "See, for example, the function signature ws(basic_­istream&amp;) ([istream.manip]).")
[🔗](#lib:operator%3e%3e,basic_istream____)
`basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
`
[3](#istream.extractors-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4879)
*Effects*: Callspf(*this)[.](#istream.extractors-3.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-3.sentence-2)
[4](#istream.extractors-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4886)
*Returns*: *this[.](#istream.extractors-4.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream_____)
`basic_istream& operator>>(ios_base& (*pf)(ios_base&));
`
[5](#istream.extractors-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4897)
*Effects*: Callspf(*this)[.](#istream.extractors-5.sentence-1)[275](#footnote-275 "See, for example, the function signature dec(ios_­base&amp;) ([basefield.manip]).")
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-5.sentence-2)
[6](#istream.extractors-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4908)
*Returns*: *this[.](#istream.extractors-6.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream______)
`template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char (&s)[N]);
`
[7](#istream.extractors-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4924)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))
of in[.](#istream.extractors-7.sentence-1)
After asentry object is constructed,operator>> extracts characters and stores them intos[.](#istream.extractors-7.sentence-2)
Ifwidth() is greater than zero, n ismin(size_t(width()), N)[.](#istream.extractors-7.sentence-3)
Otherwise n is N[.](#istream.extractors-7.sentence-4)
n is the maximum number of characters stored[.](#istream.extractors-7.sentence-5)
[8](#istream.extractors-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4941)
Characters are extracted and stored until any of the following occurs:
- [(8.1)](#istream.extractors-8.1)
n - 1 characters are stored;
- [(8.2)](#istream.extractors-8.2)
end of file occurs on the input sequence;
- [(8.3)](#istream.extractors-8.3)
letting ct be use_facet<ctype<charT>>(in.getloc()),ct.is(ct.space, c) is true[.](#istream.extractors-8.sentence-1)
[9](#istream.extractors-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4950)
operator>> then stores a null byte
(charT())
in the next position, which may be the first position if no characters
were extracted[.](#istream.extractors-9.sentence-1)
operator>> then callswidth(0)[.](#istream.extractors-9.sentence-2)
[10](#istream.extractors-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4960)
If the function extracted no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-10.sentence-1)
[11](#istream.extractors-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4965)
*Returns*: in[.](#istream.extractors-11.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream_______)
`template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
`
[12](#istream.extractors-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4981)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](#reqmts "31.7.5.3.1Common requirements"))
of in[.](#istream.extractors-12.sentence-1)
A character is extracted from in, if one is available, and stored in c[.](#istream.extractors-12.sentence-2)
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-12.sentence-3)
[13](#istream.extractors-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4990)
*Returns*: in[.](#istream.extractors-13.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream________)
`basic_istream& operator>>(basic_streambuf<charT, traits>* sb);
`
[14](#istream.extractors-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5001)
*Effects*: Behaves as an [unformatted input function](istream.unformatted "31.7.5.4Unformatted input functions[istream.unformatted]")[.](#istream.extractors-14.sentence-1)
If sb is null, callssetstate(failbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))[.](#istream.extractors-14.sentence-2)
After a sentry object is constructed, extracts
characters from*this and inserts them in the output sequence controlled by sb[.](#istream.extractors-14.sentence-3)
Characters are extracted and inserted until any of the following occurs:
- [(14.1)](#istream.extractors-14.1)
end-of-file occurs on the input sequence;
- [(14.2)](#istream.extractors-14.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(14.3)](#istream.extractors-14.3)
an exception occurs (in which case the exception is caught)[.](#istream.extractors-14.sentence-4)
[15](#istream.extractors-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5023)
If the function inserts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-15.sentence-1)
[16](#istream.extractors-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5028)
*Returns*: *this[.](#istream.extractors-16.sentence-1)
[274)](#footnote-274)[274)](#footnoteref-274)
See, for example, the function signaturews(basic_istream&) ([[istream.manip]](istream.manip "31.7.5.5Standard basic_­istream manipulators"))[.](#footnote-274.sentence-1)
[275)](#footnote-275)[275)](#footnoteref-275)
See, for example, the function signaturedec(ios_base&) ([[basefield.manip]](basefield.manip "31.5.5.3basefield manipulators"))[.](#footnote-275.sentence-1)

View File

@@ -0,0 +1,144 @@
[istream.formatted.arithmetic]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.formatted.arithmetic)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.formatted.arithmetic)
#### 31.7.5.3 Formatted input functions [[istream.formatted]](istream.formatted#arithmetic)
#### 31.7.5.3.2 Arithmetic extractors [istream.formatted.arithmetic]
[🔗](#lib:operator%3e%3e,basic_istream)
`basic_istream& operator>>(unsigned short& val);
basic_istream& operator>>(unsigned int& val);
basic_istream& operator>>(long& val);
basic_istream& operator>>(unsigned long& val);
basic_istream& operator>>(long long& val);
basic_istream& operator>>(unsigned long long& val);
basic_istream& operator>>(float& val);
basic_istream& operator>>(double& val);
basic_istream& operator>>(long double& val);
basic_istream& operator>>(bool& val);
basic_istream& operator>>(void*& val);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4713)
As in the case of the inserters, these extractors depend on the
locale's[num_get<>](locale.num.get "28.3.4.3.2Class template num_­get[locale.num.get]") object to perform parsing the input
stream data[.](#1.sentence-1)
These extractors behave as formatted input functions (as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#1.sentence-2)
After a sentry object is constructed, the
conversion occurs as if performed by the following code fragment,
where state represents the input function's local error state:using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
use_facet<numget>(loc).get(*this, 0, *this, state, val);
In the above fragment,loc stands for the private member of thebasic_ios class[.](#1.sentence-4)
[*Note [1](#note-1)*:
The first argument provides an object of theistreambuf_iterator class which is an iterator pointed to an input stream[.](#1.sentence-5)
It bypasses istreams and uses streambufs directly[.](#1.sentence-6)
— *end note*]
Classlocale relies on this
type as its interface toistream,
so that it does not need to depend directly onistream[.](#1.sentence-7)
[🔗](#lib:operator%3e%3e,basic_istream_)
`basic_istream& operator>>(short& val);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4751)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<short>::min()) { state |= ios_base::failbit;
val = numeric_limits<short>::min();} else if (numeric_limits<short>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<short>::max();} else val = static_cast<short>(lval);
[🔗](#lib:operator%3e%3e,basic_istream__)
`basic_istream& operator>>(int& val);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4775)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<int>::min()) { state |= ios_base::failbit;
val = numeric_limits<int>::min();} else if (numeric_limits<int>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<int>::max();} else val = static_cast<int>(lval);
[🔗](#itemdecl:4)
`basic_istream& operator>>(extended-floating-point-type& val);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4798)
If
the floating-point conversion rank of *extended-floating-point-type* is not less than or equal to that of long double,
then an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4806)
Otherwise, let FP be a standard floating-point type:
- [(5.1)](#5.1)
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of float,
then FP is float,
- [(5.2)](#5.2)
otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
then FP is double,
- [(5.3)](#5.3)
otherwise, FP is long double[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4822)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
FP fval;
use_facet<numget>(loc).get(*this, 0, *this, state, fval);if (fval < -numeric_limits<*extended-floating-point-type*>::max()) { state |= ios_base::failbit;
val = -numeric_limits<*extended-floating-point-type*>::max();} else if (numeric_limits<*extended-floating-point-type*>::max() < fval) { state |= ios_base::failbit;
val = numeric_limits<*extended-floating-point-type*>::max();} else { val = static_cast<*extended-floating-point-type*>(fval);}
[*Note [2](#note-2)*:
When the extended floating-point type has
a floating-point conversion rank
that is not equal to the rank of any standard floating-point type,
then double rounding during the conversion can result in inaccurate results[.](#6.sentence-1)
from_chars can be used in situations
where maximum accuracy is important[.](#6.sentence-2)
— *end note*]

View File

@@ -0,0 +1,45 @@
[istream.formatted.reqmts]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.formatted.reqmts)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.formatted.reqmts)
#### 31.7.5.3 Formatted input functions [[istream.formatted]](istream.formatted#reqmts)
#### 31.7.5.3.1 Common requirements [istream.formatted.reqmts]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4655)
Each formatted input function begins execution by constructing
an object of type ios_base::iostate, termed the local error state, and
initializing it to ios_base::goodbit[.](#1.sentence-1)
It then creates an object of classsentry with thenoskipws (second) argumentfalse[.](#1.sentence-2)
If thesentry object returnstrue,
when converted to a value of typebool,
the function endeavors
to obtain the requested input[.](#1.sentence-3)
Otherwise,
if the sentry constructor exits by throwing an exception or
if the sentry object produces false when converted to a value of type bool,
the function returns without attempting to obtain any input[.](#1.sentence-4)
If rdbuf()->sbumpc() or rdbuf()->sgetc() returns traits::eof(), thenios_base::eofbit is set in the local error state and
the input function stops trying to obtain the requested input[.](#1.sentence-5)
If an exception is thrown during input thenios_base::badbit is set in the local error state,*this's error state is set to the local error state, and
the exception is rethrown if (exceptions() & badbit) != 0[.](#1.sentence-6)
After extraction is done, the input function calls setstate, which
sets *this's error state to the local error state, and
may throw an exception[.](#1.sentence-7)
In any case, the formatted input function destroys thesentry object[.](#1.sentence-8)
If no exception has been thrown, it returns*this[.](#1.sentence-9)

View File

@@ -0,0 +1,87 @@
[istream.general]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.general)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.general)
#### 31.7.5.2 Class template basic_istream [[istream]](istream#general)
#### 31.7.5.2.1 General [istream.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4296)
When a function is specified
with a type placeholder of *extended-floating-point-type*,
the implementation provides overloads
for all cv-unqualified extended floating-point types ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))
in lieu of *extended-floating-point-type*[.](#1.sentence-1)
[🔗](#lib:basic_istream)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_istream : virtual public basic_ios<charT, traits> {public:// types (inherited from [basic_ios](ios "31.5.4Class 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; // [[istream.cons]](istream.cons "31.7.5.2.2Constructors"), constructor/destructorexplicit basic_istream(basic_streambuf<charT, traits>* sb); virtual ~basic_istream(); // [[istream.sentry]](istream.sentry "31.7.5.2.4Class basic_­istream::sentry"), prefix/suffixclass sentry; // [[istream.formatted]](istream.formatted "31.7.5.3Formatted input functions"), formatted input basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
basic_istream& operator>>(ios_base& (*pf)(ios_base&));
basic_istream& operator>>(bool& n);
basic_istream& operator>>(short& n);
basic_istream& operator>>(unsigned short& n);
basic_istream& operator>>(int& n);
basic_istream& operator>>(unsigned int& n);
basic_istream& operator>>(long& n);
basic_istream& operator>>(unsigned long& n);
basic_istream& operator>>(long long& n);
basic_istream& operator>>(unsigned long long& n);
basic_istream& operator>>(float& f);
basic_istream& operator>>(double& f);
basic_istream& operator>>(long double& f);
basic_istream& operator>>(*extended-floating-point-type*& f);
basic_istream& operator>>(void*& p);
basic_istream& operator>>(basic_streambuf<char_type, traits>* sb); // [[istream.unformatted]](istream.unformatted "31.7.5.4Unformatted input functions"), unformatted input streamsize gcount() const;
int_type get();
basic_istream& get(char_type& c);
basic_istream& get(char_type* s, streamsize n);
basic_istream& get(char_type* s, streamsize n, char_type delim);
basic_istream& get(basic_streambuf<char_type, traits>& sb);
basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
basic_istream& getline(char_type* s, streamsize n);
basic_istream& getline(char_type* s, streamsize n, char_type delim);
basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
basic_istream& ignore(streamsize n, char_type delim);
int_type peek();
basic_istream& read (char_type* s, streamsize n);
streamsize readsome(char_type* s, streamsize n);
basic_istream& putback(char_type c);
basic_istream& unget(); int sync();
pos_type tellg();
basic_istream& seekg(pos_type);
basic_istream& seekg(off_type, ios_base::seekdir); protected:// [[istream.cons]](istream.cons "31.7.5.2.2Constructors"), copy/move constructor basic_istream(const basic_istream&) = delete;
basic_istream(basic_istream&& rhs); // [[istream.assign]](istream.assign "31.7.5.2.3Assignment and swap"), assignment and swap basic_istream& operator=(const basic_istream&) = delete;
basic_istream& operator=(basic_istream&& rhs); void swap(basic_istream& rhs); }; // [[istream.extractors]](istream.extractors "31.7.5.3.3basic_­istream::operator>>"), character extraction templatestemplate<class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT&); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&); template<class charT, class traits, size_t N> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT(&)[N]); template<class traits, size_t N> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char(&)[N]); template<class traits, size_t N> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char(&)[N]);}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4399)
The class templatebasic_istream defines a number of member function
signatures that assist in reading and interpreting input from sequences
controlled by a stream buffer[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4406)
Two groups of member function signatures share common properties:
the[*formatted input functions*](#def:formatted_input_functions) (or[*extractors*](#def:extractors))
and the[*unformatted input functions.*](#def:unformatted_input_functions.) Both groups of input functions are described as if they obtain (or[*extract*](#def:extract))
input[*characters*](#def:characters) by callingrdbuf()->sbumpc() orrdbuf()->sgetc()[.](#3.sentence-1)
They may use other public members ofistream[.](#3.sentence-2)

View File

@@ -0,0 +1,201 @@
[istream.iterator]
# 24 Iterators library [[iterators]](./#iterators)
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#istream.iterator)
### 24.6.2 Class template istream_iterator [istream.iterator]
#### [24.6.2.1](#general) General [[istream.iterator.general]](istream.iterator.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6505)
The class template istream_iterator is an input iterator ([[input.iterators]](input.iterators "24.3.5.3Input iterators")) that reads successive elements
from the input stream for which it was constructed[.](#general-1.sentence-1)
namespace std {template<class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>class istream_iterator {public:using iterator_category = input_iterator_tag; using value_type = T; using difference_type = Distance; using pointer = const T*; using reference = const T&; using char_type = charT; using traits_type = traits; using istream_type = basic_istream<charT,traits>; constexpr istream_iterator(); constexpr istream_iterator(default_sentinel_t);
istream_iterator(istream_type& s); constexpr istream_iterator(const istream_iterator& x) noexcept(*see below*); ~istream_iterator() = default;
istream_iterator& operator=(const istream_iterator&) = default; const T& operator*() const; const T* operator->() const;
istream_iterator& operator++();
istream_iterator operator++(int); friend bool operator==(const istream_iterator& i, default_sentinel_t); private: basic_istream<charT,traits>* in_stream; // *exposition only* T value; // *exposition only*};}
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6547)
The type T shall meet the *Cpp17DefaultConstructible*,*Cpp17CopyConstructible*, and *Cpp17CopyAssignable* requirements[.](#general-2.sentence-1)
#### [24.6.2.2](#cons) Constructors and destructor [[istream.iterator.cons]](istream.iterator.cons)
[🔗](#lib:istream_iterator,constructor)
`constexpr istream_iterator();
constexpr istream_iterator(default_sentinel_t);
`
[1](#cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6560)
*Effects*: Constructs the end-of-stream iterator, value-initializing value[.](#cons-1.sentence-1)
[2](#cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6564)
*Postconditions*: in_stream == nullptr is true[.](#cons-2.sentence-1)
[3](#cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6568)
*Remarks*: If the initializer T() in the declaration auto x = T(); is a constant initializer ([[expr.const]](expr.const "7.7Constant expressions")),
then these constructors are constexpr constructors[.](#cons-3.sentence-1)
[🔗](#lib:istream_iterator,constructor_)
`istream_iterator(istream_type& s);
`
[4](#cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6582)
*Effects*: Initializes in_stream with addressof(s),
value-initializes value,
and then calls operator++()[.](#cons-4.sentence-1)
[🔗](#lib:istream_iterator,constructor__)
`constexpr istream_iterator(const istream_iterator& x) noexcept(see below);
`
[5](#cons-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6596)
*Effects*: Initializes in_stream with x.in_stream and
initializes value with x.value[.](#cons-5.sentence-1)
[6](#cons-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6601)
*Remarks*: An invocation of this constructor may be used in a core constant expression
if and only if the initialization of value from x.value is a constant subexpression ([[defns.const.subexpr]](defns.const.subexpr "3.15constant subexpression"))[.](#cons-6.sentence-1)
The exception specification is equivalent tois_nothrow_copy_constructible_v<T>[.](#cons-6.sentence-2)
[🔗](#lib:istream_iterator,destructor)
`~istream_iterator() = default;
`
[7](#cons-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6616)
*Remarks*: If is_trivially_destructible_v<T> is true,
then this destructor is trivial[.](#cons-7.sentence-1)
#### [24.6.2.3](#ops) Operations [[istream.iterator.ops]](istream.iterator.ops)
[🔗](#lib:operator*,istream_iterator)
`const T& operator*() const;
`
[1](#ops-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6630)
*Preconditions*: in_stream != nullptr is true[.](#ops-1.sentence-1)
[2](#ops-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6634)
*Returns*: value[.](#ops-2.sentence-1)
[🔗](#lib:operator-%3e,istream_iterator)
`const T* operator->() const;
`
[3](#ops-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6645)
*Preconditions*: in_stream != nullptr is true[.](#ops-3.sentence-1)
[4](#ops-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6649)
*Returns*: addressof(value)[.](#ops-4.sentence-1)
[🔗](#lib:operator++,istream_iterator)
`istream_iterator& operator++();
`
[5](#ops-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6660)
*Preconditions*: in_stream != nullptr is true[.](#ops-5.sentence-1)
[6](#ops-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6664)
*Effects*: Equivalent to:if (!(*in_stream >> value)) in_stream = nullptr;
[7](#ops-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6672)
*Returns*: *this[.](#ops-7.sentence-1)
[🔗](#lib:operator++,istream_iterator_)
`istream_iterator operator++(int);
`
[8](#ops-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6683)
*Preconditions*: in_stream != nullptr is true[.](#ops-8.sentence-1)
[9](#ops-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6687)
*Effects*: Equivalent to:istream_iterator tmp = *this;++*this;return tmp;
[🔗](#lib:operator==,istream_iterator)
`template<class T, class charT, class traits, class Distance>
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y);
`
[10](#ops-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6705)
*Returns*: x.in_stream == y.in_stream[.](#ops-10.sentence-1)
[🔗](#lib:operator==,istream_iterator_)
`friend bool operator==(const istream_iterator& i, default_sentinel_t);
`
[11](#ops-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6716)
*Returns*: !i.in_stream[.](#ops-11.sentence-1)

View File

@@ -0,0 +1,80 @@
[istream.iterator.cons]
# 24 Iterators library [[iterators]](./#iterators)
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#istream.iterator.cons)
### 24.6.2 Class template istream_iterator [[istream.iterator]](istream.iterator#cons)
#### 24.6.2.2 Constructors and destructor [istream.iterator.cons]
[🔗](#lib:istream_iterator,constructor)
`constexpr istream_iterator();
constexpr istream_iterator(default_sentinel_t);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6560)
*Effects*: Constructs the end-of-stream iterator, value-initializing value[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6564)
*Postconditions*: in_stream == nullptr is true[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6568)
*Remarks*: If the initializer T() in the declaration auto x = T(); is a constant initializer ([[expr.const]](expr.const "7.7Constant expressions")),
then these constructors are constexpr constructors[.](#3.sentence-1)
[🔗](#lib:istream_iterator,constructor_)
`istream_iterator(istream_type& s);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6582)
*Effects*: Initializes in_stream with addressof(s),
value-initializes value,
and then calls operator++()[.](#4.sentence-1)
[🔗](#lib:istream_iterator,constructor__)
`constexpr istream_iterator(const istream_iterator& x) noexcept(see below);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6596)
*Effects*: Initializes in_stream with x.in_stream and
initializes value with x.value[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6601)
*Remarks*: An invocation of this constructor may be used in a core constant expression
if and only if the initialization of value from x.value is a constant subexpression ([[defns.const.subexpr]](defns.const.subexpr "3.15constant subexpression"))[.](#6.sentence-1)
The exception specification is equivalent tois_nothrow_copy_constructible_v<T>[.](#6.sentence-2)
[🔗](#lib:istream_iterator,destructor)
`~istream_iterator() = default;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6616)
*Remarks*: If is_trivially_destructible_v<T> is true,
then this destructor is trivial[.](#7.sentence-1)

View File

@@ -0,0 +1,28 @@
[istream.iterator.general]
# 24 Iterators library [[iterators]](./#iterators)
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#istream.iterator.general)
### 24.6.2 Class template istream_iterator [[istream.iterator]](istream.iterator#general)
#### 24.6.2.1 General [istream.iterator.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6505)
The class template istream_iterator is an input iterator ([[input.iterators]](input.iterators "24.3.5.3Input iterators")) that reads successive elements
from the input stream for which it was constructed[.](#1.sentence-1)
namespace std {template<class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>class istream_iterator {public:using iterator_category = input_iterator_tag; using value_type = T; using difference_type = Distance; using pointer = const T*; using reference = const T&; using char_type = charT; using traits_type = traits; using istream_type = basic_istream<charT,traits>; constexpr istream_iterator(); constexpr istream_iterator(default_sentinel_t);
istream_iterator(istream_type& s); constexpr istream_iterator(const istream_iterator& x) noexcept(*see below*); ~istream_iterator() = default;
istream_iterator& operator=(const istream_iterator&) = default; const T& operator*() const; const T* operator->() const;
istream_iterator& operator++();
istream_iterator operator++(int); friend bool operator==(const istream_iterator& i, default_sentinel_t); private: basic_istream<charT,traits>* in_stream; // *exposition only* T value; // *exposition only*};}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6547)
The type T shall meet the *Cpp17DefaultConstructible*,*Cpp17CopyConstructible*, and *Cpp17CopyAssignable* requirements[.](#2.sentence-1)

View File

@@ -0,0 +1,107 @@
[istream.iterator.ops]
# 24 Iterators library [[iterators]](./#iterators)
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#istream.iterator.ops)
### 24.6.2 Class template istream_iterator [[istream.iterator]](istream.iterator#ops)
#### 24.6.2.3 Operations [istream.iterator.ops]
[🔗](#lib:operator*,istream_iterator)
`const T& operator*() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6630)
*Preconditions*: in_stream != nullptr is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6634)
*Returns*: value[.](#2.sentence-1)
[🔗](#lib:operator-%3e,istream_iterator)
`const T* operator->() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6645)
*Preconditions*: in_stream != nullptr is true[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6649)
*Returns*: addressof(value)[.](#4.sentence-1)
[🔗](#lib:operator++,istream_iterator)
`istream_iterator& operator++();
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6660)
*Preconditions*: in_stream != nullptr is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6664)
*Effects*: Equivalent to:if (!(*in_stream >> value)) in_stream = nullptr;
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6672)
*Returns*: *this[.](#7.sentence-1)
[🔗](#lib:operator++,istream_iterator_)
`istream_iterator operator++(int);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6683)
*Preconditions*: in_stream != nullptr is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6687)
*Effects*: Equivalent to:istream_iterator tmp = *this;++*this;return tmp;
[🔗](#lib:operator==,istream_iterator)
`template<class T, class charT, class traits, class Distance>
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6705)
*Returns*: x.in_stream == y.in_stream[.](#10.sentence-1)
[🔗](#lib:operator==,istream_iterator_)
`friend bool operator==(const istream_iterator& i, default_sentinel_t);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6716)
*Returns*: !i.in_stream[.](#11.sentence-1)

45
cppdraft/istream/manip.md Normal file
View File

@@ -0,0 +1,45 @@
[istream.manip]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.manip)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.manip)
#### 31.7.5.5 Standard basic_istream manipulators [istream.manip]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5735)
Each instantiation of the function template
specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#1.sentence-1)
[🔗](#lib:ws)
`template<class charT, class traits>
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5747)
*Effects*: Behaves as an [unformatted input function](istream.unformatted "31.7.5.4Unformatted input functions[istream.unformatted]"), except that it does not count the number of characters extracted and
does not affect the value returned by subsequent calls to is.gcount()[.](#2.sentence-1)
After
constructing a sentry object extracts characters as long as the next available
character c is whitespace or until there are no more characters in the sequence[.](#2.sentence-2)
Whitespace characters are distinguished with the same criterion as used by[sentry::sentry](istream.sentry "31.7.5.2.4Class basic_­istream::sentry[istream.sentry]")[.](#2.sentence-3)
Ifws stops extracting characters because there are no more available it setseofbit,
but notfailbit[.](#2.sentence-4)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5762)
*Returns*: is[.](#3.sentence-1)

View File

@@ -0,0 +1,28 @@
[istream.rvalue]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.rvalue)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.rvalue)
#### 31.7.5.6 Rvalue stream extraction [istream.rvalue]
[🔗](#lib:operator%3e%3e,basic_istream)
`template<class Istream, class T>
Istream&& operator>>(Istream&& is, T&& x);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5776)
*Constraints*: The expression is >> std::forward<T>(x) is well-formed
when treated as an [unevaluated operand](expr.context#def:unevaluated_operand "7.2.3Context dependence[expr.context]") andIstream is publicly and unambiguously derived from ios_base[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5782)
*Effects*: Equivalent to:is >> std::forward<T>(x);return std::move(is);

113
cppdraft/istream/sentry.md Normal file
View File

@@ -0,0 +1,113 @@
[istream.sentry]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.sentry)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.sentry)
#### 31.7.5.2 Class template basic_istream [[istream]](istream#sentry)
#### 31.7.5.2.4 Class basic_istream::sentry [istream.sentry]
[🔗](#lib:basic_istream::sentry)
namespace std {template<class charT, class traits>class basic_istream<charT, traits>::sentry {bool *ok_*; // *exposition only*public:explicit sentry(basic_istream& is, bool noskipws = false); ~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#L4522)
The classsentry defines a class that is responsible for doing exception safe prefix and suffix
operations[.](#1.sentence-1)
[🔗](#lib:sentry,constructor)
`explicit sentry(basic_istream& is, bool noskipws = false);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4536)
*Effects*: Ifis.good() isfalse,
calls is.setstate(failbit)[.](#2.sentence-1)
Otherwise,
prepares for formatted or
unformatted input[.](#2.sentence-2)
First, ifis.tie() is not a null pointer, the
function callsis.tie()->flush() to synchronize the output sequence with any associated external
C stream[.](#2.sentence-3)
Except that this call can be suppressed if the put area ofis.tie() is empty[.](#2.sentence-4)
Further an implementation is allowed to defer the call toflush until a
call ofis.rdbuf()->underflow() occurs[.](#2.sentence-5)
If no such call occurs before thesentry object is destroyed, the call toflush may be eliminated entirely[.](#2.sentence-6)[272](#footnote-272 "This will be possible only in functions that are part of the library. The semantics of the constructor used in user code is as specified.")
If noskipws is zero andis.flags() & ios_base::skipws is nonzero, the function extracts and discards each character as long as
the next available input character c is a whitespace character[.](#2.sentence-7)
Ifis.rdbuf()->sbumpc() oris.rdbuf()->sgetc() returnstraits::eof(),
the function callssetstate(failbit | eofbit) (which may throwios_base::failure)[.](#2.sentence-8)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4587)
*Remarks*: The constructorexplicit sentry(basic_istream& is, bool noskipws = false) uses the currently imbued locale in is,
to determine whether the next input character is
whitespace or not[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4597)
To decide if the character c is a whitespace character,
the constructor performs as if it executes the following code fragment:const ctype<charT>& ctype = use_facet<ctype<charT>>(is.getloc());if (ctype.is(ctype.space, c) != 0)// c is a whitespace character.
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4606)
If, after any preparation is completed,is.good() istrue,*ok_* != false otherwise,*ok_* == false[.](#5.sentence-1)
During preparation, the constructor may callsetstate(failbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#5.sentence-2)[273](#footnote-273 "The sentry constructor and destructor can also perform additional implementation-dependent operations.")
[🔗](#lib:sentry,destructor)
`~sentry();
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4635)
*Effects*: None[.](#6.sentence-1)
[🔗](#lib:operator_bool,basic_istream::sentry)
`explicit operator bool() const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4646)
*Returns*: *ok_*[.](#7.sentence-1)
[272)](#footnote-272)[272)](#footnoteref-272)
This will be possible only in functions
that are part of the library[.](#footnote-272.sentence-1)
The semantics of the constructor used in user code is as specified[.](#footnote-272.sentence-2)
[273)](#footnote-273)[273)](#footnoteref-273)
Thesentry constructor and destructor
can also perform additionalimplementation-dependent operations[.](#footnote-273.sentence-1)

11
cppdraft/istream/syn.md Normal file
View File

@@ -0,0 +1,11 @@
[istream.syn]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.syn)
### 31.7.1 Header <istream> synopsis [istream.syn]
[🔗](#header:%3cistream%3e)
namespace std {// [[istream]](istream "31.7.5.2Class template basic_­istream"), class template basic_istreamtemplate<class charT, class traits = char_traits<charT>>class basic_istream; using istream = basic_istream<char>; using wistream = basic_istream<wchar_t>; // [[iostreamclass]](iostreamclass "31.7.5.7Class template basic_­iostream"), class template basic_iostreamtemplate<class charT, class traits = char_traits<charT>>class basic_iostream; using iostream = basic_iostream<char>; using wiostream = basic_iostream<wchar_t>; // [[istream.manip]](istream.manip "31.7.5.5Standard basic_­istream manipulators"), standard basic_istream manipulatorstemplate<class charT, class traits> basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is); // [[istream.rvalue]](istream.rvalue "31.7.5.6Rvalue stream extraction"), rvalue stream extractiontemplate<class Istream, class T> Istream&& operator>>(Istream&& is, T&& x);}

View File

@@ -0,0 +1,674 @@
[istream.unformatted]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.unformatted)
### 31.7.5 Input streams [[input.streams]](input.streams#istream.unformatted)
#### 31.7.5.4 Unformatted input functions [istream.unformatted]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5035)
Each unformatted input function begins execution by constructing
an object of type ios_base::iostate, termed the local error state, and
initializing it to ios_base::goodbit[.](#1.sentence-1)
It then creates an object of classsentry with the default argumentnoskipws (second) argumenttrue[.](#1.sentence-2)
If thesentry object returnstrue,
when converted to a value of typebool,
the function endeavors
to obtain the requested input[.](#1.sentence-3)
Otherwise, if the sentry constructor exits by throwing an exception or if
the sentry object produces false, when converted to a value of typebool,
the function returns without attempting to obtain any input[.](#1.sentence-4)
In either case the number of extracted characters is set to 0;
unformatted input functions taking a character array of nonzero size as
an argument shall also store a null character (usingcharT())
in the first location of the array[.](#1.sentence-5)
If rdbuf()->sbumpc() or rdbuf()->sgetc() returns traits::eof(), thenios_base::eofbit is set in the local error state and
the input function stops trying to obtain the requested input[.](#1.sentence-6)
If an exception is thrown during input thenios_base::badbit is set in the local error state,*this's error state is set to the local error state, and
the exception is rethrown if (exceptions() & badbit) != 0[.](#1.sentence-7)
If no exception has been thrown it
stores the number of characters extracted
in a member object[.](#1.sentence-8)
After extraction is done, the input function calls setstate, which
sets *this's error state to the local error state, and
may throw an exception[.](#1.sentence-9)
In any event thesentry object
is destroyed before leaving the unformatted input function[.](#1.sentence-10)
[🔗](#lib:gcount,basic_istream)
`streamsize gcount() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5087)
*Effects*: None[.](#2.sentence-1)
This member function does not behave as an unformatted
input function (as described above)[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5093)
*Returns*: The number of characters
extracted by the last unformatted input member function called for the object[.](#3.sentence-1)
If the number cannot be represented,
returns numeric_limits<streamsize>::max()[.](#3.sentence-2)
[🔗](#lib:get,basic_istream)
`int_type get();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5107)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#4.sentence-1)
After constructing a sentry object, extracts
a character c, if one is available[.](#4.sentence-2)
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#4.sentence-3)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5117)
*Returns*: c if available,
otherwisetraits::eof()[.](#5.sentence-1)
[🔗](#lib:get,basic_istream_)
`basic_istream& get(char_type& c);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5130)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#6.sentence-1)
After constructing a sentry object, extracts
a character, if one is available, and assigns it to c[.](#6.sentence-2)[276](#footnote-276 "Note that this function is not overloaded on types signed char and unsigned char.")
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#6.sentence-3)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5147)
*Returns*: *this[.](#7.sentence-1)
[🔗](#lib:get,basic_istream__)
`basic_istream& get(char_type* s, streamsize n, char_type delim);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5158)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#8.sentence-1)
After constructing a sentry object, extracts
characters and stores them
into successive locations of an array whose first element is designated bys[.](#8.sentence-2)[277](#footnote-277 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until any of the following occurs:
- [(8.1)](#8.1)
n is less than one or n - 1 characters are stored;
- [(8.2)](#8.2)
end-of-file occurs on the input sequence;
- [(8.3)](#8.3)
traits::eq(c, delim) for the next available input
character c (in which case c is not extracted)[.](#8.sentence-3)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5186)
If the function stores no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#9.sentence-1)
In any case, if n is greater than zero it then stores a null character
into the next successive location of the array[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5193)
*Returns*: *this[.](#10.sentence-1)
[🔗](#lib:get,basic_istream___)
`basic_istream& get(char_type* s, streamsize n);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5204)
*Effects*: Callsget(s, n, widen('\n'))[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5209)
*Returns*: Value returned by the call[.](#12.sentence-1)
[🔗](#lib:get,basic_istream____)
`basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5220)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#13.sentence-1)
After constructing a sentry object, extracts
characters and inserts them
in the output sequence controlled bysb[.](#13.sentence-2)
Characters are extracted and inserted until any of the following occurs:
- [(13.1)](#13.1)
end-of-file occurs on the input sequence;
- [(13.2)](#13.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(13.3)](#13.3)
traits::eq(c, delim) for the next available input
character c (in which case c is not extracted);
- [(13.4)](#13.4)
an exception occurs
(in which case, the exception is caught but not rethrown)[.](#13.sentence-3)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5244)
If the function inserts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5249)
*Returns*: *this[.](#15.sentence-1)
[🔗](#lib:get,basic_istream_____)
`basic_istream& get(basic_streambuf<char_type, traits>& sb);
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5260)
*Effects*: Callsget(sb, widen('\n'))[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5265)
*Returns*: Value returned by the call[.](#17.sentence-1)
[🔗](#lib:getline,basic_istream)
`basic_istream& getline(char_type* s, streamsize n, char_type delim);
`
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5276)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#18.sentence-1)
After constructing a sentry object, extracts
characters and stores them
into successive locations of an array whose first element is designated bys[.](#18.sentence-2)[278](#footnote-278 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until one of the following occurs:
| [1.](#18.1) | end-of-file occurs on the input sequence; |
| --- | --- |
| [2.](#18.2) | traits::eq(c, delim) for the next available input character c (in which case the input character is extracted but not stored);[279](#footnote-279 "Since the final input character is “extracted”, it is counted in the gcount(), even though it is not stored.") |
| [3.](#18.3) | n is less than one or n - 1 characters are stored (in which case the function calls setstate(failbit))[.](#18.sentence-3) |
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5313)
These conditions are tested in the order shown[.](#19.sentence-1)[280](#footnote-280 "This allows an input line which exactly fills the buffer, without setting failbit. This is different behavior than the historical AT&amp;T implementation.")
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5322)
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#20.sentence-1)[281](#footnote-281 "This implies an empty input line will not cause failbit to be set.")
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5333)
In any case, if n is greater than zero, it then stores a null character
(usingcharT())
into the next successive location of the array[.](#21.sentence-1)
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5339)
*Returns*: *this[.](#22.sentence-1)
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5343)
[*Example [1](#example-1)*: #include <iostream>int main() {using namespace std; const int line_buffer_size = 100; char buffer[line_buffer_size]; int line_number = 0; while (cin.getline(buffer, line_buffer_size, '\n') || cin.gcount()) {int count = cin.gcount(); if (cin.eof()) cout << "Partial final line"; // cin.fail() is falseelse if (cin.fail()) { cout << "Partial long line";
cin.clear(cin.rdstate() & ~ios_base::failbit); } else { count--; // Don't include newline in count cout << "Line " << ++line_number; } cout << " (" << count << " chars): " << buffer << endl; }} — *end example*]
[🔗](#lib:getline,basic_istream_)
`basic_istream& getline(char_type* s, streamsize n);
`
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5378)
*Returns*: getline(s, n, widen('\n'))[.](#24.sentence-1)
[🔗](#lib:ignore,basic_istream)
`basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
`
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5389)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#25.sentence-1)
After constructing a sentry object, extracts
characters and discards them[.](#25.sentence-2)
Characters are extracted until any of the following occurs:
- [(25.1)](#25.1)
n != [numeric_limits<streamsize>::max()](numeric.limits.members#lib:numeric_limits,max "17.3.5.2numeric_­limits members[numeric.limits.members]")numeric.limits andn characters have been extracted so far;
- [(25.2)](#25.2)
end-of-file occurs on the input sequence
(in which case the function callssetstate(eofbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")));
- [(25.3)](#25.3)
traits::eq_int_type(traits::to_int_type(c), delim) for the next available input character c (in which case c is extracted)[.](#25.sentence-3)
[*Note [1](#note-1)*:
The last condition will never occur iftraits::eq_int_type(delim, traits::eof())[.](#25.sentence-4)
— *end note*]
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5417)
*Returns*: *this[.](#26.sentence-1)
[🔗](#lib:ignore,basic_istream_)
`basic_istream& ignore(streamsize n, char_type delim);
`
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5428)
*Constraints*: is_same_v<char_type, char> is true[.](#27.sentence-1)
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5432)
*Effects*: Equivalent to: return ignore(n, traits::to_int_type(delim));
[🔗](#lib:peek,basic_istream)
`int_type peek();
`
[29](#29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5443)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#29.sentence-1)
After constructing a sentry object, reads but does not extract
the current input character[.](#29.sentence-2)
[30](#30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5450)
*Returns*: traits::eof() ifgood() isfalse[.](#30.sentence-1)
Otherwise, returnsrdbuf()->sgetc()[.](#30.sentence-2)
[🔗](#lib:read,basic_istream)
`basic_istream& read(char_type* s, streamsize n);
`
[31](#31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5467)
*Effects*: Behaves as an unformatted input function (as described above)[.](#31.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#31.sentence-2)
Otherwise extracts characters and stores them
into successive locations of an array whose first element is designated bys[.](#31.sentence-3)[282](#footnote-282 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until either of the following occurs:
- [(31.1)](#31.1)
n characters are stored;
- [(31.2)](#31.2)
end-of-file occurs on the input sequence
(in which case the function callssetstate(failbit | eofbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#31.sentence-4)
[32](#32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5498)
*Returns*: *this[.](#32.sentence-1)
[🔗](#lib:readsome,basic_istream)
`streamsize readsome(char_type* s, streamsize n);
`
[33](#33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5509)
*Effects*: Behaves as an unformatted input function (as described above)[.](#33.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#33.sentence-2)
Otherwise extracts characters and stores them
into successive locations of an array whose first element is designated bys[.](#33.sentence-3)
Ifrdbuf()->in_avail() == -1,
callssetstate(eofbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))),
and extracts no characters;
- [(33.1)](#33.1)
Ifrdbuf()->in_avail() == 0,
extracts no characters
- [(33.2)](#33.2)
Ifrdbuf()->in_avail() > 0,
extractsmin(rdbuf()->in_avail(), n))[.](#33.sentence-4)
[34](#34)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5541)
*Returns*: The number of characters extracted[.](#34.sentence-1)
[🔗](#lib:putback,basic_istream)
`basic_istream& putback(char_type c);
`
[35](#35)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5552)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit[.](#35.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#35.sentence-2)
Ifrdbuf() is not null, callsrdbuf()->sputbackc(c)[.](#35.sentence-3)
Ifrdbuf() is null, or ifsputbackc returnstraits::eof(),
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#35.sentence-4)
[*Note [2](#note-2)*:
This
function extracts no characters, so the value returned by the next call togcount() is 0[.](#35.sentence-5)
— *end note*]
[36](#36)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5583)
*Returns*: *this[.](#36.sentence-1)
[🔗](#lib:unget,basic_istream)
`basic_istream& unget();
`
[37](#37)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5594)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit[.](#37.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#37.sentence-2)
Ifrdbuf() is not null, callsrdbuf()->sungetc()[.](#37.sentence-3)
Ifrdbuf() is null, or ifsungetc returnstraits::eof(),
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#37.sentence-4)
[*Note [3](#note-3)*:
This
function extracts no characters, so the value returned by the next call togcount() is 0[.](#37.sentence-5)
— *end note*]
[38](#38)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5625)
*Returns*: *this[.](#38.sentence-1)
[🔗](#lib:sync,basic_istream)
`int sync();
`
[39](#39)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5636)
*Effects*: Behaves as an unformatted input function (as described above), except that it does not
count the number of characters extracted and does not affect the
value returned by subsequent calls togcount()[.](#39.sentence-1)
After constructing
a sentry object, ifrdbuf() is a null pointer, returns -1[.](#39.sentence-2)
Otherwise, callsrdbuf()->pubsync() and, if that function returns -1 callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")),
and returns-1[.](#39.sentence-3)
Otherwise, returns zero[.](#39.sentence-4)
[🔗](#lib:tellg,basic_istream)
`pos_type tellg();
`
[40](#40)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5664)
*Effects*: Behaves as an unformatted input function (as described above), except that it does not count
the number of characters extracted and does not affect the value
returned by subsequent calls togcount()[.](#40.sentence-1)
[41](#41)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5671)
*Returns*: After constructing a sentry object, iffail() != false,
returnspos_type(-1) to indicate failure[.](#41.sentence-1)
Otherwise, returnsrdbuf()->pubseekoff(0, cur, in)[.](#41.sentence-2)
[🔗](#lib:seekg,basic_istream)
`basic_istream& seekg(pos_type pos);
`
[42](#42)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5688)
*Effects*: Behaves as an unformatted input function (as described above), except that
the function first clears eofbit,
it does not count
the number of characters extracted, and it does not affect the value
returned by subsequent calls togcount()[.](#42.sentence-1)
After constructing a sentry object, iffail() != true,
executesrdbuf()->pubseekpos(pos, ios_base::in)[.](#42.sentence-2)
In case of failure, the function callssetstate(failbit) (which may throwios_base::failure)[.](#42.sentence-3)
[43](#43)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5705)
*Returns*: *this[.](#43.sentence-1)
[🔗](#lib:seekg,basic_istream_)
`basic_istream& seekg(off_type off, ios_base::seekdir dir);
`
[44](#44)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5716)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit,
does not count the number of characters extracted, and
does not affect the value returned by subsequent calls to gcount()[.](#44.sentence-1)
After constructing a sentry object, iffail() != true,
executesrdbuf()->pubseekoff(off, dir, ios_base::in)[.](#44.sentence-2)
In case of failure, the function calls setstate(failbit) (which may throwios_base::failure)[.](#44.sentence-3)
[45](#45)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5728)
*Returns*: *this[.](#45.sentence-1)
[276)](#footnote-276)[276)](#footnoteref-276)
Note
that this function is not overloaded on typessigned char andunsigned char[.](#footnote-276.sentence-1)
[277)](#footnote-277)[277)](#footnoteref-277)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-277.sentence-1)
[278)](#footnote-278)[278)](#footnoteref-278)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-278.sentence-1)
[279)](#footnote-279)[279)](#footnoteref-279)
Since
the final input character is “extracted”,
it is counted in thegcount(),
even though it is not stored[.](#footnote-279.sentence-1)
[280)](#footnote-280)[280)](#footnoteref-280)
This allows an input
line which exactly fills the buffer, without settingfailbit[.](#footnote-280.sentence-1)
This is different behavior than the historical AT&T implementation[.](#footnote-280.sentence-2)
[281)](#footnote-281)[281)](#footnoteref-281)
This implies an
empty input line will not causefailbit to be set[.](#footnote-281.sentence-1)
[282)](#footnote-282)[282)](#footnoteref-282)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-282.sentence-1)