Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.streambuf.sgetn.stdcxx-1026.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <istream>
31#include <streambuf>
32
33int main ()
34{
35 static int x = '0';
36
37 struct MyBuf : std::streambuf {
38 // unbuffered, always successfully reads one character
39 int_type underflow () {
40 assert (gptr () == egptr ());
41 return x++;
42 }
43 } sb;
44
45 // "endless" stream that never reaches EOF
46 std::istream endless (&sb);
47
48 char s [4] = "";
49
50 endless.read (s, sizeof s);
51
52 // expect to find stream in good state (i.e., not EOF) and
53 // to have extracted as many characters as requested with
54 // just as many calls to underflow()
55 assert (endless.good ());
56 assert (sizeof s == endless.gcount ());
57 assert ('0' == s [0] && '1' == s [1] && '2' == s [2] && '3' == s [3]);
58}
#define sb
Definition 17.names.cpp:542
#define x
Definition 17.names.cpp:140
#define s
#define assert(expr)
Definition _cassert.h:40