1473 lines
61 KiB
Markdown
1473 lines
61 KiB
Markdown
[input.streams]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#input.streams)
|
||
|
||
### 31.7.5 Input streams [input.streams]
|
||
|
||
#### [31.7.5.1](#general) General [[input.streams.general]](input.streams.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4287)
|
||
|
||
The header [<istream>](istream.syn#header:%3cistream%3e "31.7.1 Header <istream> synopsis [istream.syn]") defines two class templates
|
||
and a function template that control input from a stream buffer,
|
||
along with a function template that extracts from stream rvalues[.](#general-1.sentence-1)
|
||
|
||
#### [31.7.5.2](#istream) Class template basic_istream [[istream]](istream)
|
||
|
||
#### [31.7.5.2.1](#istream.general) General [[istream.general]](istream.general)
|
||
|
||
[1](#istream.general-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.2 Fundamental types"))
|
||
in lieu of *extended-floating-point-type*[.](#istream.general-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.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; // [[istream.cons]](#istream.cons "31.7.5.2.2 Constructors"), constructor/destructorexplicit basic_istream(basic_streambuf<charT, traits>* sb); virtual ~basic_istream(); // [[istream.sentry]](#istream.sentry "31.7.5.2.4 Class basic_istream::sentry"), prefix/suffixclass sentry; // [[istream.formatted]](#istream.formatted "31.7.5.3 Formatted 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.4 Unformatted 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.2 Constructors"), copy/move constructor basic_istream(const basic_istream&) = delete;
|
||
basic_istream(basic_istream&& rhs); // [[istream.assign]](#istream.assign "31.7.5.2.3 Assignment 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.3 basic_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](#istream.general-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[.](#istream.general-2.sentence-1)
|
||
|
||
[3](#istream.general-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()[.](#istream.general-3.sentence-1)
|
||
|
||
They may use other public members ofistream[.](#istream.general-3.sentence-2)
|
||
|
||
#### [31.7.5.2.2](#istream.cons) Constructors [[istream.cons]](istream.cons)
|
||
|
||
[ð](#lib:basic_istream,constructor)
|
||
|
||
`explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
||
`
|
||
|
||
[1](#istream.cons-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.2 Constructors"))[.](#istream.cons-1.sentence-1)
|
||
|
||
[2](#istream.cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4439)
|
||
|
||
*Postconditions*: gcount() == 0[.](#istream.cons-2.sentence-1)
|
||
|
||
[ð](#lib:basic_istream,constructor_)
|
||
|
||
`basic_istream(basic_istream&& rhs);
|
||
`
|
||
|
||
[3](#istream.cons-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[.](#istream.cons-3.sentence-1)
|
||
|
||
[ð](#lib:basic_istream,destructor)
|
||
|
||
`virtual ~basic_istream();
|
||
`
|
||
|
||
[4](#istream.cons-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4465)
|
||
|
||
*Remarks*: Does not perform any operations ofrdbuf()[.](#istream.cons-4.sentence-1)
|
||
|
||
#### [31.7.5.2.3](#istream.assign) Assignment and swap [[istream.assign]](istream.assign)
|
||
|
||
[ð](#lib:operator=,basic_istream)
|
||
|
||
`basic_istream& operator=(basic_istream&& rhs);
|
||
`
|
||
|
||
[1](#istream.assign-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4479)
|
||
|
||
*Effects*: Equivalent to swap(rhs)[.](#istream.assign-1.sentence-1)
|
||
|
||
[2](#istream.assign-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4483)
|
||
|
||
*Returns*: *this[.](#istream.assign-2.sentence-1)
|
||
|
||
[ð](#lib:swap,basic_istream)
|
||
|
||
`void swap(basic_istream& rhs);
|
||
`
|
||
|
||
[3](#istream.assign-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4494)
|
||
|
||
*Effects*: Calls basic_ios<charT, traits>::swap(rhs)[.](#istream.assign-3.sentence-1)
|
||
|
||
Exchanges the values returned by gcount() andrhs.gcount()[.](#istream.assign-3.sentence-2)
|
||
|
||
#### [31.7.5.2.4](#istream.sentry) Class basic_istream::sentry [[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](#istream.sentry-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[.](#istream.sentry-1.sentence-1)
|
||
|
||
[ð](#lib:sentry,constructor)
|
||
|
||
`explicit sentry(basic_istream& is, bool noskipws = false);
|
||
`
|
||
|
||
[2](#istream.sentry-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4536)
|
||
|
||
*Effects*: Ifis.good() isfalse,
|
||
calls is.setstate(failbit)[.](#istream.sentry-2.sentence-1)
|
||
|
||
Otherwise,
|
||
prepares for formatted or
|
||
unformatted input[.](#istream.sentry-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[.](#istream.sentry-2.sentence-3)
|
||
|
||
Except that this call can be suppressed if the put area ofis.tie() is empty[.](#istream.sentry-2.sentence-4)
|
||
|
||
Further an implementation is allowed to defer the call toflush until a
|
||
call ofis.rdbuf()->underflow() occurs[.](#istream.sentry-2.sentence-5)
|
||
|
||
If no such call occurs before thesentry object is destroyed, the call toflush may be eliminated entirely[.](#istream.sentry-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[.](#istream.sentry-2.sentence-7)
|
||
|
||
Ifis.rdbuf()->sbumpc() oris.rdbuf()->sgetc() returnstraits::eof(),
|
||
the function callssetstate(failbit | eofbit) (which may throwios_base::failure)[.](#istream.sentry-2.sentence-8)
|
||
|
||
[3](#istream.sentry-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[.](#istream.sentry-3.sentence-1)
|
||
|
||
[4](#istream.sentry-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](#istream.sentry-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[.](#istream.sentry-5.sentence-1)
|
||
|
||
During preparation, the constructor may callsetstate(failbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#istream.sentry-5.sentence-2)[273](#footnote-273 "The sentry constructor and destructor can also perform additional implementation-dependent operations.")
|
||
|
||
[ð](#lib:sentry,destructor)
|
||
|
||
`~sentry();
|
||
`
|
||
|
||
[6](#istream.sentry-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4635)
|
||
|
||
*Effects*: None[.](#istream.sentry-6.sentence-1)
|
||
|
||
[ð](#lib:operator_bool,basic_istream::sentry)
|
||
|
||
`explicit operator bool() const;
|
||
`
|
||
|
||
[7](#istream.sentry-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4646)
|
||
|
||
*Returns*: *ok_*[.](#istream.sentry-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)
|
||
|
||
#### [31.7.5.3](#istream.formatted) Formatted input functions [[istream.formatted]](istream.formatted)
|
||
|
||
#### [31.7.5.3.1](#istream.formatted.reqmts) Common requirements [[istream.formatted.reqmts]](istream.formatted.reqmts)
|
||
|
||
[1](#istream.formatted.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[.](#istream.formatted.reqmts-1.sentence-1)
|
||
|
||
It then creates an object of classsentry with thenoskipws (second) argumentfalse[.](#istream.formatted.reqmts-1.sentence-2)
|
||
|
||
If thesentry object returnstrue,
|
||
when converted to a value of typebool,
|
||
the function endeavors
|
||
to obtain the requested input[.](#istream.formatted.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[.](#istream.formatted.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[.](#istream.formatted.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[.](#istream.formatted.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[.](#istream.formatted.reqmts-1.sentence-7)
|
||
|
||
In any case, the formatted input function destroys thesentry object[.](#istream.formatted.reqmts-1.sentence-8)
|
||
|
||
If no exception has been thrown, it returns*this[.](#istream.formatted.reqmts-1.sentence-9)
|
||
|
||
#### [31.7.5.3.2](#istream.formatted.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](#istream.formatted.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.2 Class template num_get [locale.num.get]") object to perform parsing the input
|
||
stream data[.](#istream.formatted.arithmetic-1.sentence-1)
|
||
|
||
These extractors behave as formatted input functions (as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1 Common requirements"))[.](#istream.formatted.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[.](#istream.formatted.arithmetic-1.sentence-4)
|
||
|
||
[*Note [1](#istream.formatted.arithmetic-note-1)*:
|
||
|
||
The first argument provides an object of theistreambuf_iterator class which is an iterator pointed to an input stream[.](#istream.formatted.arithmetic-1.sentence-5)
|
||
|
||
It bypasses istreams and uses streambufs directly[.](#istream.formatted.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[.](#istream.formatted.arithmetic-1.sentence-7)
|
||
|
||
[ð](#lib:operator%3e%3e,basic_istream_)
|
||
|
||
`basic_istream& operator>>(short& val);
|
||
`
|
||
|
||
[2](#istream.formatted.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](#istream.formatted.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);
|
||
|
||
[ð](#istream.formatted.arithmetic-itemdecl:4)
|
||
|
||
`basic_istream& operator>>(extended-floating-point-type& val);
|
||
`
|
||
|
||
[4](#istream.formatted.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[.](#istream.formatted.arithmetic-4.sentence-1)
|
||
|
||
[5](#istream.formatted.arithmetic-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4806)
|
||
|
||
Otherwise, let FP be a standard floating-point type:
|
||
|
||
- [(5.1)](#istream.formatted.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)](#istream.formatted.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)](#istream.formatted.arithmetic-5.3)
|
||
|
||
otherwise, FP is long double[.](#istream.formatted.arithmetic-5.sentence-1)
|
||
|
||
[6](#istream.formatted.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](#istream.formatted.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[.](#istream.formatted.arithmetic-6.sentence-1)
|
||
|
||
from_chars can be used in situations
|
||
where maximum accuracy is important[.](#istream.formatted.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]](#istream.formatted.reqmts "31.7.5.3.1 Common 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&) ([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]](#istream.formatted.reqmts "31.7.5.3.1 Common 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&) ([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.1 Common 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]](#istream.formatted.reqmts "31.7.5.3.1 Common 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]](#istream.formatted.reqmts "31.7.5.3.1 Common 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.4 Unformatted 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.4 Flags 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.5 Standard 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.3 basefield manipulators"))[.](#footnote-275.sentence-1)
|
||
|
||
#### [31.7.5.4](#istream.unformatted) Unformatted input functions [[istream.unformatted]](istream.unformatted)
|
||
|
||
[1](#istream.unformatted-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[.](#istream.unformatted-1.sentence-1)
|
||
|
||
It then creates an object of classsentry with the default argumentnoskipws (second) argumenttrue[.](#istream.unformatted-1.sentence-2)
|
||
|
||
If thesentry object returnstrue,
|
||
when converted to a value of typebool,
|
||
the function endeavors
|
||
to obtain the requested input[.](#istream.unformatted-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[.](#istream.unformatted-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[.](#istream.unformatted-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[.](#istream.unformatted-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[.](#istream.unformatted-1.sentence-7)
|
||
|
||
If no exception has been thrown it
|
||
stores the number of characters extracted
|
||
in a member object[.](#istream.unformatted-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[.](#istream.unformatted-1.sentence-9)
|
||
|
||
In any event thesentry object
|
||
is destroyed before leaving the unformatted input function[.](#istream.unformatted-1.sentence-10)
|
||
|
||
[ð](#lib:gcount,basic_istream)
|
||
|
||
`streamsize gcount() const;
|
||
`
|
||
|
||
[2](#istream.unformatted-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5087)
|
||
|
||
*Effects*: None[.](#istream.unformatted-2.sentence-1)
|
||
|
||
This member function does not behave as an unformatted
|
||
input function (as described above)[.](#istream.unformatted-2.sentence-2)
|
||
|
||
[3](#istream.unformatted-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[.](#istream.unformatted-3.sentence-1)
|
||
|
||
If the number cannot be represented,
|
||
returns numeric_limits<streamsize>::max()[.](#istream.unformatted-3.sentence-2)
|
||
|
||
[ð](#lib:get,basic_istream)
|
||
|
||
`int_type get();
|
||
`
|
||
|
||
[4](#istream.unformatted-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5107)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-4.sentence-1)
|
||
|
||
After constructing a sentry object, extracts
|
||
a character c, if one is available[.](#istream.unformatted-4.sentence-2)
|
||
|
||
Otherwise,ios_base::failbit is set in the input function's local error state
|
||
before setstate is called[.](#istream.unformatted-4.sentence-3)
|
||
|
||
[5](#istream.unformatted-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5117)
|
||
|
||
*Returns*: c if available,
|
||
otherwisetraits::eof()[.](#istream.unformatted-5.sentence-1)
|
||
|
||
[ð](#lib:get,basic_istream_)
|
||
|
||
`basic_istream& get(char_type& c);
|
||
`
|
||
|
||
[6](#istream.unformatted-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5130)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-6.sentence-1)
|
||
|
||
After constructing a sentry object, extracts
|
||
a character, if one is available, and assigns it to c[.](#istream.unformatted-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[.](#istream.unformatted-6.sentence-3)
|
||
|
||
[7](#istream.unformatted-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5147)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-7.sentence-1)
|
||
|
||
[ð](#lib:get,basic_istream__)
|
||
|
||
`basic_istream& get(char_type* s, streamsize n, char_type delim);
|
||
`
|
||
|
||
[8](#istream.unformatted-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5158)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-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[.](#istream.unformatted-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)](#istream.unformatted-8.1)
|
||
|
||
n is less than one or n - 1 characters are stored;
|
||
|
||
- [(8.2)](#istream.unformatted-8.2)
|
||
|
||
end-of-file occurs on the input sequence;
|
||
|
||
- [(8.3)](#istream.unformatted-8.3)
|
||
|
||
traits::eq(c, delim) for the next available input
|
||
character c (in which case c is not extracted)[.](#istream.unformatted-8.sentence-3)
|
||
|
||
[9](#istream.unformatted-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[.](#istream.unformatted-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[.](#istream.unformatted-9.sentence-2)
|
||
|
||
[10](#istream.unformatted-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5193)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-10.sentence-1)
|
||
|
||
[ð](#lib:get,basic_istream___)
|
||
|
||
`basic_istream& get(char_type* s, streamsize n);
|
||
`
|
||
|
||
[11](#istream.unformatted-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5204)
|
||
|
||
*Effects*: Callsget(s, n, widen('\n'))[.](#istream.unformatted-11.sentence-1)
|
||
|
||
[12](#istream.unformatted-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5209)
|
||
|
||
*Returns*: Value returned by the call[.](#istream.unformatted-12.sentence-1)
|
||
|
||
[ð](#lib:get,basic_istream____)
|
||
|
||
`basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
|
||
`
|
||
|
||
[13](#istream.unformatted-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5220)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-13.sentence-1)
|
||
|
||
After constructing a sentry object, extracts
|
||
characters and inserts them
|
||
in the output sequence controlled bysb[.](#istream.unformatted-13.sentence-2)
|
||
|
||
Characters are extracted and inserted until any of the following occurs:
|
||
|
||
- [(13.1)](#istream.unformatted-13.1)
|
||
|
||
end-of-file occurs on the input sequence;
|
||
|
||
- [(13.2)](#istream.unformatted-13.2)
|
||
|
||
inserting in the output sequence fails
|
||
(in which case the character to be inserted is not extracted);
|
||
|
||
- [(13.3)](#istream.unformatted-13.3)
|
||
|
||
traits::eq(c, delim) for the next available input
|
||
character c (in which case c is not extracted);
|
||
|
||
- [(13.4)](#istream.unformatted-13.4)
|
||
|
||
an exception occurs
|
||
(in which case, the exception is caught but not rethrown)[.](#istream.unformatted-13.sentence-3)
|
||
|
||
[14](#istream.unformatted-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[.](#istream.unformatted-14.sentence-1)
|
||
|
||
[15](#istream.unformatted-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5249)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-15.sentence-1)
|
||
|
||
[ð](#lib:get,basic_istream_____)
|
||
|
||
`basic_istream& get(basic_streambuf<char_type, traits>& sb);
|
||
`
|
||
|
||
[16](#istream.unformatted-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5260)
|
||
|
||
*Effects*: Callsget(sb, widen('\n'))[.](#istream.unformatted-16.sentence-1)
|
||
|
||
[17](#istream.unformatted-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5265)
|
||
|
||
*Returns*: Value returned by the call[.](#istream.unformatted-17.sentence-1)
|
||
|
||
[ð](#lib:getline,basic_istream)
|
||
|
||
`basic_istream& getline(char_type* s, streamsize n, char_type delim);
|
||
`
|
||
|
||
[18](#istream.unformatted-18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5276)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-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[.](#istream.unformatted-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.](#istream.unformatted-18.1) | end-of-file occurs on the input sequence; |
|
||
| --- | --- |
|
||
| [2.](#istream.unformatted-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.](#istream.unformatted-18.3) | n is less than one or n - 1 characters are stored (in which case the function calls setstate(failbit))[.](#istream.unformatted-18.sentence-3) |
|
||
|
||
[19](#istream.unformatted-19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5313)
|
||
|
||
These conditions are tested in the order shown[.](#istream.unformatted-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&T implementation.")
|
||
|
||
[20](#istream.unformatted-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[.](#istream.unformatted-20.sentence-1)[281](#footnote-281 "This implies an empty input line will not cause failbit to be set.")
|
||
|
||
[21](#istream.unformatted-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[.](#istream.unformatted-21.sentence-1)
|
||
|
||
[22](#istream.unformatted-22)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5339)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-22.sentence-1)
|
||
|
||
[23](#istream.unformatted-23)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5343)
|
||
|
||
[*Example [1](#istream.unformatted-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](#istream.unformatted-24)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5378)
|
||
|
||
*Returns*: getline(s, n, widen('\n'))[.](#istream.unformatted-24.sentence-1)
|
||
|
||
[ð](#lib:ignore,basic_istream)
|
||
|
||
`basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
|
||
`
|
||
|
||
[25](#istream.unformatted-25)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5389)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-25.sentence-1)
|
||
|
||
After constructing a sentry object, extracts
|
||
characters and discards them[.](#istream.unformatted-25.sentence-2)
|
||
|
||
Characters are extracted until any of the following occurs:
|
||
|
||
- [(25.1)](#istream.unformatted-25.1)
|
||
|
||
n != [numeric_limits<streamsize>::max()](numeric.limits.members#lib:numeric_limits,max "17.3.5.2 numeric_limits members [numeric.limits.members]")numeric.limits andn characters have been extracted so far;
|
||
|
||
- [(25.2)](#istream.unformatted-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.4 Flags functions")));
|
||
|
||
- [(25.3)](#istream.unformatted-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)[.](#istream.unformatted-25.sentence-3)
|
||
|
||
[*Note [1](#istream.unformatted-note-1)*:
|
||
|
||
The last condition will never occur iftraits::eq_int_type(delim, traits::eof())[.](#istream.unformatted-25.sentence-4)
|
||
|
||
â *end note*]
|
||
|
||
[26](#istream.unformatted-26)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5417)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-26.sentence-1)
|
||
|
||
[ð](#lib:ignore,basic_istream_)
|
||
|
||
`basic_istream& ignore(streamsize n, char_type delim);
|
||
`
|
||
|
||
[27](#istream.unformatted-27)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5428)
|
||
|
||
*Constraints*: is_same_v<char_type, char> is true[.](#istream.unformatted-27.sentence-1)
|
||
|
||
[28](#istream.unformatted-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](#istream.unformatted-29)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5443)
|
||
|
||
*Effects*: Behaves as an unformatted input function
|
||
(as described above)[.](#istream.unformatted-29.sentence-1)
|
||
|
||
After constructing a sentry object, reads but does not extract
|
||
the current input character[.](#istream.unformatted-29.sentence-2)
|
||
|
||
[30](#istream.unformatted-30)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5450)
|
||
|
||
*Returns*: traits::eof() ifgood() isfalse[.](#istream.unformatted-30.sentence-1)
|
||
|
||
Otherwise, returnsrdbuf()->sgetc()[.](#istream.unformatted-30.sentence-2)
|
||
|
||
[ð](#lib:read,basic_istream)
|
||
|
||
`basic_istream& read(char_type* s, streamsize n);
|
||
`
|
||
|
||
[31](#istream.unformatted-31)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5467)
|
||
|
||
*Effects*: Behaves as an unformatted input function (as described above)[.](#istream.unformatted-31.sentence-1)
|
||
|
||
After constructing
|
||
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
|
||
and return[.](#istream.unformatted-31.sentence-2)
|
||
|
||
Otherwise extracts characters and stores them
|
||
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-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)](#istream.unformatted-31.1)
|
||
|
||
n characters are stored;
|
||
|
||
- [(31.2)](#istream.unformatted-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.4 Flags functions")))[.](#istream.unformatted-31.sentence-4)
|
||
|
||
[32](#istream.unformatted-32)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5498)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-32.sentence-1)
|
||
|
||
[ð](#lib:readsome,basic_istream)
|
||
|
||
`streamsize readsome(char_type* s, streamsize n);
|
||
`
|
||
|
||
[33](#istream.unformatted-33)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5509)
|
||
|
||
*Effects*: Behaves as an unformatted input function (as described above)[.](#istream.unformatted-33.sentence-1)
|
||
|
||
After constructing
|
||
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
|
||
and return[.](#istream.unformatted-33.sentence-2)
|
||
|
||
Otherwise extracts characters and stores them
|
||
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-33.sentence-3)
|
||
|
||
Ifrdbuf()->in_avail() == -1,
|
||
callssetstate(eofbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions"))),
|
||
and extracts no characters;
|
||
|
||
- [(33.1)](#istream.unformatted-33.1)
|
||
|
||
Ifrdbuf()->in_avail() == 0,
|
||
extracts no characters
|
||
|
||
- [(33.2)](#istream.unformatted-33.2)
|
||
|
||
Ifrdbuf()->in_avail() > 0,
|
||
extractsmin(rdbuf()->in_avail(), n))[.](#istream.unformatted-33.sentence-4)
|
||
|
||
[34](#istream.unformatted-34)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5541)
|
||
|
||
*Returns*: The number of characters extracted[.](#istream.unformatted-34.sentence-1)
|
||
|
||
[ð](#lib:putback,basic_istream)
|
||
|
||
`basic_istream& putback(char_type c);
|
||
`
|
||
|
||
[35](#istream.unformatted-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[.](#istream.unformatted-35.sentence-1)
|
||
|
||
After constructing
|
||
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
|
||
and return[.](#istream.unformatted-35.sentence-2)
|
||
|
||
Ifrdbuf() is not null, callsrdbuf()->sputbackc(c)[.](#istream.unformatted-35.sentence-3)
|
||
|
||
Ifrdbuf() is null, or ifsputbackc returnstraits::eof(),
|
||
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#istream.unformatted-35.sentence-4)
|
||
|
||
[*Note [2](#istream.unformatted-note-2)*:
|
||
|
||
This
|
||
function extracts no characters, so the value returned by the next call togcount() is 0[.](#istream.unformatted-35.sentence-5)
|
||
|
||
â *end note*]
|
||
|
||
[36](#istream.unformatted-36)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5583)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-36.sentence-1)
|
||
|
||
[ð](#lib:unget,basic_istream)
|
||
|
||
`basic_istream& unget();
|
||
`
|
||
|
||
[37](#istream.unformatted-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[.](#istream.unformatted-37.sentence-1)
|
||
|
||
After constructing
|
||
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
|
||
and return[.](#istream.unformatted-37.sentence-2)
|
||
|
||
Ifrdbuf() is not null, callsrdbuf()->sungetc()[.](#istream.unformatted-37.sentence-3)
|
||
|
||
Ifrdbuf() is null, or ifsungetc returnstraits::eof(),
|
||
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions")))[.](#istream.unformatted-37.sentence-4)
|
||
|
||
[*Note [3](#istream.unformatted-note-3)*:
|
||
|
||
This
|
||
function extracts no characters, so the value returned by the next call togcount() is 0[.](#istream.unformatted-37.sentence-5)
|
||
|
||
â *end note*]
|
||
|
||
[38](#istream.unformatted-38)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5625)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-38.sentence-1)
|
||
|
||
[ð](#lib:sync,basic_istream)
|
||
|
||
`int sync();
|
||
`
|
||
|
||
[39](#istream.unformatted-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()[.](#istream.unformatted-39.sentence-1)
|
||
|
||
After constructing
|
||
a sentry object, ifrdbuf() is a null pointer, returns -1[.](#istream.unformatted-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.4 Flags functions")),
|
||
and returns-1[.](#istream.unformatted-39.sentence-3)
|
||
|
||
Otherwise, returns zero[.](#istream.unformatted-39.sentence-4)
|
||
|
||
[ð](#lib:tellg,basic_istream)
|
||
|
||
`pos_type tellg();
|
||
`
|
||
|
||
[40](#istream.unformatted-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()[.](#istream.unformatted-40.sentence-1)
|
||
|
||
[41](#istream.unformatted-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[.](#istream.unformatted-41.sentence-1)
|
||
|
||
Otherwise, returnsrdbuf()->pubseekoff(0, cur, in)[.](#istream.unformatted-41.sentence-2)
|
||
|
||
[ð](#lib:seekg,basic_istream)
|
||
|
||
`basic_istream& seekg(pos_type pos);
|
||
`
|
||
|
||
[42](#istream.unformatted-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()[.](#istream.unformatted-42.sentence-1)
|
||
|
||
After constructing a sentry object, iffail() != true,
|
||
executesrdbuf()->pubseekpos(pos, ios_base::in)[.](#istream.unformatted-42.sentence-2)
|
||
|
||
In case of failure, the function callssetstate(failbit) (which may throwios_base::failure)[.](#istream.unformatted-42.sentence-3)
|
||
|
||
[43](#istream.unformatted-43)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5705)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-43.sentence-1)
|
||
|
||
[ð](#lib:seekg,basic_istream_)
|
||
|
||
`basic_istream& seekg(off_type off, ios_base::seekdir dir);
|
||
`
|
||
|
||
[44](#istream.unformatted-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()[.](#istream.unformatted-44.sentence-1)
|
||
|
||
After constructing a sentry object, iffail() != true,
|
||
executesrdbuf()->pubseekoff(off, dir, ios_base::in)[.](#istream.unformatted-44.sentence-2)
|
||
|
||
In case of failure, the function calls setstate(failbit) (which may throwios_base::failure)[.](#istream.unformatted-44.sentence-3)
|
||
|
||
[45](#istream.unformatted-45)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5728)
|
||
|
||
*Returns*: *this[.](#istream.unformatted-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)
|
||
|
||
#### [31.7.5.5](#istream.manip) Standard basic_istream manipulators [[istream.manip]](istream.manip)
|
||
|
||
[1](#istream.manip-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.1 Namespace std"))[.](#istream.manip-1.sentence-1)
|
||
|
||
[ð](#lib:ws_)
|
||
|
||
`template<class charT, class traits>
|
||
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
|
||
`
|
||
|
||
[2](#istream.manip-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5747)
|
||
|
||
*Effects*: Behaves as an [unformatted input function](#istream.unformatted "31.7.5.4 Unformatted 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()[.](#istream.manip-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[.](#istream.manip-2.sentence-2)
|
||
|
||
Whitespace characters are distinguished with the same criterion as used by[sentry::sentry](#istream.sentry "31.7.5.2.4 Class basic_istream::sentry [istream.sentry]")[.](#istream.manip-2.sentence-3)
|
||
|
||
Ifws stops extracting characters because there are no more available it setseofbit,
|
||
but notfailbit[.](#istream.manip-2.sentence-4)
|
||
|
||
[3](#istream.manip-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5762)
|
||
|
||
*Returns*: is[.](#istream.manip-3.sentence-1)
|
||
|
||
#### [31.7.5.6](#istream.rvalue) Rvalue stream extraction [[istream.rvalue]](istream.rvalue)
|
||
|
||
[ð](#lib:operator%3e%3e,basic_istream_________)
|
||
|
||
`template<class Istream, class T>
|
||
Istream&& operator>>(Istream&& is, T&& x);
|
||
`
|
||
|
||
[1](#istream.rvalue-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.3 Context dependence [expr.context]") andIstream is publicly and unambiguously derived from ios_base[.](#istream.rvalue-1.sentence-1)
|
||
|
||
[2](#istream.rvalue-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5782)
|
||
|
||
*Effects*: Equivalent to:is >> std::forward<T>(x);return std::move(is);
|
||
|
||
#### [31.7.5.7](#iostreamclass) Class template basic_iostream [[iostreamclass]](iostreamclass)
|
||
|
||
#### [31.7.5.7.1](#iostreamclass.general) General [[iostreamclass.general]](iostreamclass.general)
|
||
|
||
[ð](#lib:basic_iostream)
|
||
|
||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_iostream : public basic_istream<charT, traits>, public basic_ostream<charT, traits> {public: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; // [[iostream.cons]](#iostream.cons "31.7.5.7.2 Constructors"), constructorexplicit basic_iostream(basic_streambuf<charT, traits>* sb); // [[iostream.dest]](#iostream.dest "31.7.5.7.3 Destructor"), destructorvirtual ~basic_iostream(); protected:// [[iostream.cons]](#iostream.cons "31.7.5.7.2 Constructors"), constructor basic_iostream(const basic_iostream&) = delete;
|
||
basic_iostream(basic_iostream&& rhs); // [[iostream.assign]](#iostream.assign "31.7.5.7.4 Assignment and swap"), assignment and swap basic_iostream& operator=(const basic_iostream&) = delete;
|
||
basic_iostream& operator=(basic_iostream&& rhs); void swap(basic_iostream& rhs); };}
|
||
|
||
[1](#iostreamclass.general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5828)
|
||
|
||
The class templatebasic_iostream inherits a number of functions that allow reading input and writing output to
|
||
sequences controlled by a stream buffer[.](#iostreamclass.general-1.sentence-1)
|
||
|
||
#### [31.7.5.7.2](#iostream.cons) Constructors [[iostream.cons]](iostream.cons)
|
||
|
||
[ð](#lib:basic_iostream,constructor)
|
||
|
||
`explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
||
`
|
||
|
||
[1](#iostream.cons-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5842)
|
||
|
||
*Effects*: Initializes the base class subobjects withbasic_istream<charT, traits>(sb) ([[istream]](#istream "31.7.5.2 Class template basic_istream"))
|
||
and[basic_ostream<charT, traits>(sb)](ostream "31.7.6.2 Class template basic_ostream [ostream]")[.](#iostream.cons-1.sentence-1)
|
||
|
||
[2](#iostream.cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5849)
|
||
|
||
*Postconditions*: rdbuf() == sb andgcount() == 0[.](#iostream.cons-2.sentence-1)
|
||
|
||
[ð](#lib:basic_iostream,constructor_)
|
||
|
||
`basic_iostream(basic_iostream&& rhs);
|
||
`
|
||
|
||
[3](#iostream.cons-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5862)
|
||
|
||
*Effects*: Move constructs from the rvalue rhs by
|
||
constructing the basic_istream base class withstd::move(rhs)[.](#iostream.cons-3.sentence-1)
|
||
|
||
#### [31.7.5.7.3](#iostream.dest) Destructor [[iostream.dest]](iostream.dest)
|
||
|
||
[ð](#lib:basic_iostream,destructor)
|
||
|
||
`virtual ~basic_iostream();
|
||
`
|
||
|
||
[1](#iostream.dest-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5877)
|
||
|
||
*Remarks*: Does not perform any operations onrdbuf()[.](#iostream.dest-1.sentence-1)
|
||
|
||
#### [31.7.5.7.4](#iostream.assign) Assignment and swap [[iostream.assign]](iostream.assign)
|
||
|
||
[ð](#lib:operator=,basic_iostream)
|
||
|
||
`basic_iostream& operator=(basic_iostream&& rhs);
|
||
`
|
||
|
||
[1](#iostream.assign-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5891)
|
||
|
||
*Effects*: Equivalent to swap(rhs)[.](#iostream.assign-1.sentence-1)
|
||
|
||
[ð](#lib:swap,basic_iostream)
|
||
|
||
`void swap(basic_iostream& rhs);
|
||
`
|
||
|
||
[2](#iostream.assign-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5902)
|
||
|
||
*Effects*: Calls basic_istream<charT, traits>::swap(rhs)[.](#iostream.assign-2.sentence-1)
|