🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2649

string::getline(): a minor extension

#2649
From: Dietmar Kuehl
Date: Mon, 20 Nov 1995 00:03
31 lines
1931 bytes
Hi,

This is not again the problem with the 'failbit' :-) It's something
else...  The function 'string::getline()' is declared like this:

  template <class charT, class IS_traits, class STR_traits, class STR_alloc>
  basic_istream<charT, IS_traits>
    &basic_string<charT, STR_traits, STR_alloc>::getline(
      basic_istream<chart, IS_traits> &in,
      basic_string<charT, STR_traits, STR_alloc> &str,
      charT delim = IS_traits::newline())

Why is the 'delim' argument declared to be 'charT' instead of
'IS_traits::int_type'? If 'delim' is a 'IS_traits::int_type' the
following would be possible:

  istream &in; // initialized somewhere
  string  rest_of_file;
  getline(in, rest_of_file, ios_traits<char>::eof());

This would read (if nothing else than the declaration of 'getline()' is
modified) the rest of the file into the string ('rest_of_file' in this
case).
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl
I am a realistic optimist - that's why I appear to be slightly pessimistic

[ 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: <48o1c5$ens@eurybia.rz.uni-konstanz.de>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: kuehl@uzwil.rz.uni-konstanz.de (Dietmar Kuehl)
Newsgroups: comp.std.c++
Subject: string::getline(): a minor extension
Date: 20 Nov 1995 00:03:37 GMT
Organization: Fakultdt f|r Mathematik und Informatik
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <48o1c5$ens@eurybia.rz.uni-konstanz.de>
Reply-To: Dietmar.Kuehl@uni-konstanz.de
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
Summary: Making use of 'eof()' in 'string::getline()'
X-Nntp-Posting-Host: uzwil.informatik.uni-konstanz.de
X-Newsreader: TIN [version 1.1 PL6]
Content-Length: 1028
Originator: clamage@taumet