Article View: comp.std.c++
Article #2612string::getline() and null lines
From: 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. ]
Technical Details
Message-ID:
<48j00a$la8@rap.SanDiegoCA.ATTGIS.COM>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: Art Kaufmann <afk@elsegundoca.attgis.com> Newsgroups: comp.std.c++ Subject: string::getline() and null lines Date: 17 Nov 1995 23:18:18 GMT Organization: AT&T Global Information Solutions Approved: clamage@eng.sun.com (comp.std.c++) Distribution: world Message-ID: <48j00a$la8@rap.SanDiegoCA.ATTGIS.COM> Reply-To: afk@elsegundoca.attgis.com NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: hostsw6.elsegundoca.attgis.com Content-Length: 1264 Originator: clamage@taumet