istream::putback
problemSection: 31.7.5.4 [istream.unformatted] Status: C++20 Submitter: Juan Soulie Opened: 2013-03-01 Last modified: 2021-02-25
Priority: 3
View all other issues in [istream.unformatted].
View all issues with C++20 status.
Discussion:
In 31.7.5.4 [istream.unformatted] / 34, when describing putback
, it says that "rdbuf->sputbackc()
"
is called. The problem are not the obvious typos in the expression, but the fact that it may lead to different
interpretations, since nowhere is specified what the required argument to sputbackc
is.
rdbuf()->sputbackc(c)
", but "rdbuf()->sputbackc(char_type())
" or
just anything would be as conforming (or non-conforming) as the first guess.
[2017-12-12, Jonathan comments and provides wording]
Fix the bogus expression, and change sputbackc()
to just sputbackc
since we're talking about the function, not an expression sputbackc()
(which
isn't a valid expression any more than rdbuf->sputbackc()
is). Make the
corresponding change to the equivalent wording in p36 too.
[ 2017-12-14 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
This wording is relative to N4713.
Change 31.7.5.4 [istream.unformatted] as shown:
basic_istream<charT, traits>& putback(char_type c);-34- Effects: Behaves as an unformatted input function (as described above), except that the function first clears
-35- Returns:eofbit
. After constructing a sentry object, if!good()
callssetstate(failbit)
which may throw an exception, and return. Ifrdbuf()
is not null, callsrdbuf()->sputbackc(c)
. Ifrdbuf()
is null, or ifsputbackc
returns()traits::eof()
, callssetstate(badbit)
(which may throwios_base::failure
(31.5.4.4 [iostate.flags])). [Note: This function extracts no characters, so the value returned by the next call togcount()
is0
. — end note]*this
.basic_istream<charT, traits>& unget();-36- Effects: Behaves as an unformatted input function (as described above), except that the function first clears
-37- Returns:eofbit
. After constructing a sentry object, if!good()
callssetstate(failbit)
which may throw an exception, and return. Ifrdbuf()
is not null, callsrdbuf()->sungetc()
. Ifrdbuf()
is null, or ifsungetc
returns()traits::eof()
, callssetstate(badbit)
(which may throwios_base::failure
(31.5.4.4 [iostate.flags])). [Note: This function extracts no characters, so the value returned by the next call togcount()
is0
. — end note]*this
.