Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
21.string.io.stdcxx-250.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <istream>
31#include <string>
32
33int main ()
34{
35 struct MyBuf : std::streambuf {
36 int_type underflow () {
37 static int i = 0;
38 // i == 0: sgect() invoked from sentry ctor
39 // i == 1: sgetc() invoked from operator>>()
40 // i == 2: sbumpc() invoked from operator>>()
41 return 1 < i++ ? throw i : 'x';
42 }
43 } buf;
44
45 std::istream is (&buf);
46
47 std::string s;
48 is >> s;
49
50 assert ("x" == s);
51 assert ((is.failbit | is.badbit) == is.rdstate ());
52
53 return 0;
54}
#define i
Definition 17.names.cpp:126
#define buf
Definition 17.names.cpp:452
#define s
#define assert(expr)
Definition _cassert.h:40