Files
cppdraft_translate/cppdraft/istream/extractors.md
2025-10-25 03:02:53 +03:00

7.5 KiB
Raw Blame History

[istream.extractors]

31 Input/output library [input.output]

31.7 Formatting and manipulators [iostream.format]

31.7.5 Input streams [input.streams]

31.7.5.3 Formatted input functions [istream.formatted]

31.7.5.3.3 basic_istream::operator>> [istream.extractors]

🔗

basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));

1

#

Effects: None.

This extractor does not behave as a formatted input function (as described in [istream.formatted.reqmts]).

2

#

Returns: pf(*this).

274

🔗

basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));

3

#

Effects: Callspf(*this).

This extractor does not behave as a formatted input function (as described in [istream.formatted.reqmts]).

4

#

Returns: *this.

🔗

basic_istream& operator>>(ios_base& (*pf)(ios_base&));

5

#

Effects: Callspf(*this).275

This extractor does not behave as a formatted input function (as described in [istream.formatted.reqmts]).

6

#

Returns: *this.

🔗

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

#

Effects: Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of in.

After asentry object is constructed,operator>> extracts characters and stores them intos.

Ifwidth() is greater than zero, n ismin(size_t(width()), N).

Otherwise n is N.

n is the maximum number of characters stored.

8

#

Characters are extracted and stored until any of the following occurs:

n - 1 characters are stored;

end of file occurs on the input sequence;

letting ct be use_facet<ctype>(in.getloc()),ct.is(ct.space, c) is true.

9

#

operator>> then stores a null byte (charT()) in the next position, which may be the first position if no characters were extracted.

operator>> then callswidth(0).

10

#

If the function extracted no characters,ios_base::failbit is set in the input function's local error state before setstate is called.

11

#

Returns: in.

🔗

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

#

Effects: Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of in.

A character is extracted from in, if one is available, and stored in c.

Otherwise,ios_base::failbit is set in the input function's local error state before setstate is called.

13

#

Returns: in.

🔗

basic_istream& operator>>(basic_streambuf<charT, traits>* sb);

14

#

Effects: Behaves as an unformatted input function.

If sb is null, callssetstate(failbit), which may throwios_base::failure ([iostate.flags]).

After a sentry object is constructed, extracts characters from*this and inserts them in the output sequence controlled by sb.

Characters are extracted and inserted until any of the following occurs:

end-of-file occurs on the input sequence;

inserting in the output sequence fails (in which case the character to be inserted is not extracted);

an exception occurs (in which case the exception is caught).

15

#

If the function inserts no characters,ios_base::failbit is set in the input function's local error state before setstate is called.

16

#

Returns: *this.

274)274)

See, for example, the function signaturews(basic_istream&) ([istream.manip]).

275)275)

See, for example, the function signaturedec(ios_base&) ([basefield.manip]).