Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!mips!ardent!jra!jss From: jss@jra.ardent.com Newsgroups: comp.lang.c++ Subject: Re: Why isn't ostream::osfx/opfx virtual? Message-ID: <9805@ardent.UUCP> Date: 21 Dec 89 19:35:43 GMT References: <1989Dec18.141217.19738@odi.com> Sender: news@ardent.UUCP Reply-To: jss@jra.ardent.com () Organization: Ardent Computer Corp., Sunnyvale, CA Lines: 31 In article <1989Dec18.141217.19738@odi.com> benson@odi.com () writes: >In 2.0, ostream has two functions osfx and opfx that are used to give >the stream control (for buffering purposes) before and after output. >They aren't virtual. > >As per my previous message, I need to implement some specializations >of ostream that are sensitive to line boundaries. osfx would serve >my purposes fine -- if it were virtual. > What these functions do is check for special conditions inline and and then call out of line code to deal with these special conditions as necessary. Since all this involves private data it was not appropriate to specify exactly what they would have to do and it was therefore not appropriate to make them virtual. They are part of the public interface so that they can be called by user defined inserters. There is also the efficiency consideration, that making them virtual would have had a significant performance impact on the char inserter. As I suggested in another note, the best way to deal with this sort of thing within the iostream interface is to put the special handling into the streambuf rather than the ostream. It is possible to cause flush to be called on every character by making sure the streambuf always looks "full" even when there is still room in the arrays. Jerry Schwarz