Article View: comp.std.c++
Article #2439Re: a gotcha in getline(istream,string) -- why...?
From: James Kanze US/ESC 60/3/141 #407...
Date: Mon, 06 Nov 1995 21:08
Date: Mon, 06 Nov 1995 21:08
42 lines
2411 bytes
2411 bytes
In article <martelli.815502013@cadlab> martelli@cadlab.it (Alex
Martelli) writes:
|> Trying to explain to a newbie how to do input by whole lines in C++,
|> the way they easily used to do it with fgets in bad ol' C, I got bit
|> (besides a bug in the libg++ implementation of getline(), which just
|> points to some obscurity between the standard libraries' usages of
|> length/size/capacity for strings -- obscurity enough to confuse the
|> implementor) by a gotcha in the standard itself:
|> per paragraph 21.1.1.10.8, "Inserters and extractors", getline()...:
|> If the function appends no characters, it calls
|> is.setstate(failbit), which may throw ios_base::failure
In the public draft, the statement in 27.6.1.3 (where the target is a
char[]) is: "If the function *extracts* no characters...". A quick
check with an old cfront based compiler (Sun CC 2.1) shows that this
was the case for the original AT&T implementation, too (unless Sun
changed something, which I very much doubt). Thus, I expect that the
above is just a typographical error, and that `extracts' is what is
meant there, too.
The library working group did an amazing amount of work just before
the draft was made public, and the editor (and his assistants) had to
work like crazy to get it in in time. Under these conditions, I don't
find it particularly surprising that there are a number of these sort
of errors.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
---
[ 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:
<9511061110.AA12225@lts.sel.alcatel.de>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<martelli.815502013@cadlab>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> Newsgroups: comp.std.c++ Subject: Re: a gotcha in getline(istream,string) -- why...? Date: 06 Nov 1995 21:08:04 GMT Organization: <none> Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <9511061110.AA12225@lts.sel.alcatel.de> References: <martelli.815502013@cadlab> NNTP-Posting-Host: physics2.berkeley.edu