Topic: iostream prefix & suffix virtual?
Author: 74221.306@compuserve.com (Jean-Louis Leroy)
Date: 1996/04/29 Raw View
Hello,
my copy of the DWP (April 95) shows that basic_istream::ipfx(),
basic_istream::isfx(), basic_ostream::opfx() and basic_ostream::osfx()
are still nonvirtual functions.
Are there any real objections against them virtual? basic_istream and
basic_ostream already have a virtual dtor, hence a vtable. These four
functions are not inlines. The cost would be insignificant, wouldn't
it?
I see at least one problem virtual prefixes and suffixes would help to
solve: implement ostreams that automatically wrap lines to a certain
length. This is a problem I consistently run into in real life when I
need to output lines that consist of a (variable-length) label
followed by a (variable-length) list of numbers and ensure no line is
longer than 80 characters.
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: kanze@gabi-soft.fr (J. Kanze)
Date: 1996/05/02 Raw View
In article <4m2k4k$4ab@dub-news-svc-6.compuserve.com>
74221.306@compuserve.com (Jean-Louis Leroy) writes:
|> my copy of the DWP (April 95) shows that basic_istream::ipfx(),
|> basic_istream::isfx(), basic_ostream::opfx() and basic_ostream::osfx()
|> are still nonvirtual functions.
|> Are there any real objections against them virtual? basic_istream and
|> basic_ostream already have a virtual dtor, hence a vtable. These four
|> functions are not inlines. The cost would be insignificant, wouldn't
|> it?
|> I see at least one problem virtual prefixes and suffixes would help to
|> solve: implement ostreams that automatically wrap lines to a certain
|> length. This is a problem I consistently run into in real life when I
|> need to output lines that consist of a (variable-length) label
|> followed by a (variable-length) list of numbers and ensure no line is
|> longer than 80 characters.
I don't quite see how making osfx and opfx would help here. The correct
solution is to derive from streambuf. In this particular case, I would
probably use the forwarding streambuf pattern, which I described in a
recent posting to comp.lang.c++.moderated.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]