Files
2025-10-25 03:02:53 +03:00

222 lines
7.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

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

[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&) ([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)