Thread View: comp.std.c++
2 messages
2 total messages
Started by Art Kaufmann
Fri, 17 Nov 1995 23:18
string::getline() and null lines
Author: Art Kaufmann
Date: Fri, 17 Nov 1995 23:18
Date: Fri, 17 Nov 1995 23:18
32 lines
2077 bytes
2077 bytes
The following is an excerpt from the April WP, p 21-25, section
31.1.1.10.8:
-- c == delim for the next available input character c(in which case the
input character is extracted from is, but not appended to str).
If the function appends no characters, it calls is.setstate(failbit),
which may throw ios_base::failure(27.4.4.3).
My question is: Why indicate a failure when no characters are appended? This
means that string::getline() cannot be used in a situation where you may get
a null line (two consecutive delim characters), since there is no way to
differentiate between this kind of "failure" and something more serious.
The definition of failure (p 27-13, Table 69-iostate effects) is "that an
input operation failed to read the expected characters, or that an
output operation failed to generate the desired characters." I "expect"
getline() to read from 0 to npos-1 characters, not 1 to npos-1, as the
former is _far_ more useful to me.
Cheers,
Art
---
Art Kaufmann |
afk@ElSegundoCA.ATTGIS.COM |
--------------------------------------------------------------------------------
"... and should anyone actually read this drivel, any knowlege of your actions
will be denied by AT&T Global Information Solutions"
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: string::getline() and null lines
Author: Steve Clamage
Date: Sat, 18 Nov 1995 03:18
Date: Sat, 18 Nov 1995 03:18
21 lines
1487 bytes
1487 bytes
Art Kaufmann <afk@elsegundoca.attgis.com> writes: >The following is an excerpt from the April WP, p 21-25, section >21.1.1.10.8: > -- c == delim for the next available input character c(in which case the > input character is extracted from is, but not appended to str). > If the function appends no characters, it calls is.setstate(failbit), > which may throw ios_base::failure(27.4.4.3). >My question is: Why indicate a failure when no characters are appended? The wording has been modified in the September draft to say an error is indicated when no characters have been *extracted*. -- Steve Clamage, stephen.clamage@eng.sun.com --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads