From -7189995118441146576
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7243bb67dd016622
X-Google-Attributes: gidf78e5,public
From: Matt Austern <austern@sgi.com>
Subject: Re: basic_streambuf<>::in_avail()
Date: 1999/03/19
Message-ID: <fxtaex9e1i1.fsf@isolde.engr.sgi.com>#1/1
X-Deja-AN: 456617953
X-NNTP-Posting-Host: isolde.engr.sgi.com
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <%PUH2.5770$_n2.114958@carnaval.risq.qc.ca> <7crtbm$k14$1@shell7.ba.best.com> <7cttn9$s10$4@news.BelWue.DE>
X-UID: 0000000001
X-Status: $$$T
Organization: SGI
Newsgroups: comp.std.c++
Originator: clamage@taumet


kuehl@wolfurt.informatik.uni-konstanz.de (Dietmar Kuehl) writes:

> : in_avail() in this example should return 1.  If it fails to do so,
> : you have a library bug.
> 
> I think it is correct that 0 is returned: All standard streams maintain
> only one joint position for reading and writing. After writing one character
> into the stream, the write and read positions are pointing to the character
> just behind the just inserted character. There is none. Thus, no character
> is available for the stream and 'in_avail()' returns 0. To have 'in_avail()'
> return 1 it would be necessary to seek back to the beginning of the stream.

That's true for basic_filebuf, but I think Nathan is right about
basic_stringbuf.  There's a lot of text in 27.7.1 that only makes
sense if the read and write positions are separate (see, for example,
the discussion of positioning in Table 90, which explicitly says that
the user can reposition one of the the read and write positions
without changing the other), and I can't find any text to suggest that
basic_stringbuf has a joint read/write position.

My interpretation of basic_stringbuf<>::overflow() (27.7.1.3,
paragraph 5) is that it should not change the position of the get
pointer.  In my implementation I go to some trouble to make sure 
of that.


[ 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              ]




