Thread View: comp.std.c++
1 messages
1 total messages
Started by Dietmar Kuehl
Mon, 20 Nov 1995 00:03
string::getline(): a minor extension
Author: Dietmar Kuehl
Date: Mon, 20 Nov 1995 00:03
Date: Mon, 20 Nov 1995 00:03
31 lines
1931 bytes
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 ∈ // 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. ]
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