This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.
Section: 31.7.5.4 [istream.unformatted] Status: C++14 Submitter: Krzysztof Żelechowski Opened: 2011-09-11 Last modified: 2016-08-09
Priority: Not Prioritized
View all other issues in [istream.unformatted].
View all issues with C++14 status.
Discussion:
31.7.5.4 [istream.unformatted] in N3242 currently has the following to say about the semantics of basic_istream::ignore:
[..]. Characters are extracted until any of the following occurs:
- if n != numeric_limits<streamsize>::max() (18.3.2), n characters are extracted
This statement, apart from being slightly ungrammatical, indicates that if (n == numeric_limits<streamsize>::max()), the method returns without extracting any characters.
The description intends to describe the observable behaviour of an implementation in terms of logical assertions. Logical assertions are not "bullets" that can be "entered" but need not; they are predicates that can evaluate to true or false. The description contains two predicates, either of them causes extraction to terminate. In the incriminated case, the first predicate is evaluates to true because its premise is false, therefore no characters will be extracted. The intended semantics would be described by the following statement:[..]. Characters are extracted until any of the following occurs:
- (n != numeric_limits<streamsize>::max()) (18.3.2) and (n) characters have been extracted so far.
[2013-04-20, Bristol]
Resolution: Ready.
[2013-09-29, Chicago]
Apply to Working Paper
Proposed resolution:
This wording is relative to the FDIS.
Change 31.7.5.4 [istream.unformatted] p25 as indicated:
basic_istream<charT,traits>& ignore(streamsize n = 1, int_type delim = traits::eof());-25- Effects: Behaves as an unformatted input function (as described in 31.7.5.4 [istream.unformatted], paragraph 1). After constructing a sentry object, extracts characters and discards them. Characters are extracted until any of the following occurs:
ifn != numeric_limits<streamsize>::max() ( [limits.numeric]),and n charactersarehave been extracted so far- end-of-file occurs on the input sequence (in which case the function calls setstate(eofbit), which may throw ios_base::failure (31.5.4.4 [iostate.flags]));
- traits::eq_int_type(traits::to_int_type(c), delim) for the next available input character c (in which case c is extracted).