|
Boost : |
From: deansturtevant_at_[hidden]
Date: 2001-03-06 18:58:17
--- In boost_at_y..., "E. Karpachov" <jk_at_s...> wrote:
> On Tue, Mar 06, 2001 at 02:11:10PM -0000, Paul Carter wrote:
> > i/ What should the end-user interface look like? Obviously, it's
> > going to look quite like std::iostream, but there are variations.
>
> Isn't std::streambuf better? Then we could utilize some obscure
methods like
> std::streambuf::in_avail() etc.
>
Funny he should mention this. I was just playing around with this,
based on a comment Bjarne made in "The C++ Programming Language,
Third Edition", p. 647. He says
"A call to in_avail() is used to see how many characters are
available in the buffer. This can be used to avoid waiting for input."
And he gives the example:
if (cin.rdbuf().in_avail()) {
cin.get(c);
// do something
}
else {
// do something else
}
I tried coding this up (fixing the typo: should be cin.rdbuf()-
>in_avail()). But no dice with MSVC or GCC or STLPort. Are all these
implementations buggy? Or is Bjorne's interpretation incorrect? Or is
my interpretation of Bjorne incorrect?
If it's not in the standard to test for data available, is this
because the committee was unduly influenced by implementers who
didn't feel like implementing this properly? Or was it an oversight?
Or maybe it couldn't be implemented on ALL platforms? In the latter
case I agree with the political statement that says: If there's
something useful that doesn't work on all platforms, at least provide
a common specification for how it should work! (And probably also the
means for detecting whether it works on a platform).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk