Topic: Getline but no 'putline
Author: Barry Margolin <barmar@bbnplanet.com>
Date: 1998/07/06 Raw View
In article <6ni8it$p5s$1@shell7.ba.best.com>,
Nathan Myers <ncm@nospam.cantrip.org> wrote:
>Edward Diener <eddielee@abraxis.com> wrote:
>>The getline member function exists for the basic_istream class, and can
>>be used with the string class and basic_istream, but there is no
>>'putline' or equivalent with basic_ostream in the C++ standard library.
>>Was there any reason for this ? I realize a 'putline' can be done very
>>simply but I am just questioning why a 'putline' or equivalent was not
>>implemented for orthogonality.
>
>Nobody proposed one. That's the reason for most things you don't
>see in the library.
But even if it had been proposed, I wouldn't be surprised if it had been
rejected. It's trivial and unnecessary -- it's simple to just output '\n'
or endl. On the other hand, reading until a newline is a little more
complicated -- for good performance, it's may be best to deal directly with
the input buffer. While it's not a very hard task to write "read until
newline", it's so common that it makes sense to package it up to avoid this
hassle.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/07/07 Raw View
Barry Margolin <barmar@bbnplanet.com> wrote:
>Nathan Myers <ncm@nospam.cantrip.org> wrote:
>>Edward Diener <eddielee@abraxis.com> wrote:
>>>The getline member function exists for the basic_istream class, and can
>>>be used with the string class and basic_istream, but there is no
>>>'putline' or equivalent with basic_ostream in the C++ standard library.
>>
>>Nobody proposed one. That's the reason for most things you don't
>>see in the library.
>
>... reading until a newline is a little more complicated [than putline
>would be] -- for good performance, it may be best to deal directly with
>the input buffer.
That's the long answer to the unasked question: why is there a getline,
given that there is no putline? (My apologies for glibness. Barry
identified the right question.) Getline offers optimization
opportunities to the implementor, where putline would not.
--
Nathan Myers
ncm@nospam.cantrip.org http://www.cantrip.org/
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Edward Diener <eddielee@abraxis.com>
Date: 1998/07/03 Raw View
The getline member function exists for the basic_istream class, and can
be used with the string class and basic_istream, but there is no
'putline' or equivalent with basic_ostream in the C++ standard library.
Was there any reason for this ? I realize a 'putline' can be done very
simply but I am just questioning why a 'putline' or equivalent was not
implemented for orthogonality.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/07/03 Raw View
Edward Diener <eddielee@abraxis.com> wrote:
>The getline member function exists for the basic_istream class, and can
>be used with the string class and basic_istream, but there is no
>'putline' or equivalent with basic_ostream in the C++ standard library.
>Was there any reason for this ? I realize a 'putline' can be done very
>simply but I am just questioning why a 'putline' or equivalent was not
>implemented for orthogonality.
Nobody proposed one. That's the reason for most things you don't
see in the library.
--
Nathan Myers
ncm@nospam.cantrip.org http://www.cantrip.org/
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]