Boost logo

Boost :

From: pinkfloydhomer_at_[hidden]
Date: 2001-03-07 01:42:11

--- In boost_at_y..., deansturtevant_at_m... wrote:

> 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
> 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
> implementations buggy? Or is Bjorne's interpretation incorrect? Or
> my interpretation of Bjorne incorrect?

The above code was exactly what I tried first, and expected to work.
If it just worked as you (and I) initially expected, all _my_
problems in this particular case, would be solved. That is, if
in_avail could answer the question: "If you try to fetch a char from
cin now, I won't block, even if my buffer is now empty."

Boost list run by bdawes at, gregod at, cpdaniel at, john at