Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
tests
regress
27.ostream.unformatted.stdcxx-626.cpp
Go to the documentation of this file.
1
29
#include <cassert>
30
#include <ostream>
31
32
int
sync_calls
;
33
34
struct
MyBuf
: std::streambuf
35
{
36
virtual
int
sync
() {
37
++
sync_calls
;
38
return
-1;
39
}
40
};
41
42
43
int
main
()
44
{
45
MyBuf
buf
;
46
47
std::ostream
os
(&
buf
);
48
49
// verify that ostream::flush() doesn't call streambuf::sync()
50
// when the state of the stream isn't good
51
52
os
.setstate (
os
.badbit);
53
54
os
.flush ();
55
56
assert
(0 ==
sync_calls
);
57
58
os
.setstate (
os
.eofbit);
59
60
os
.flush ();
61
62
assert
(0 ==
sync_calls
);
63
64
os
.setstate (
os
.failbit);
65
66
os
.flush ();
67
68
assert
(0 ==
sync_calls
);
69
70
return
0;
71
}
os
#define os
Definition
17.names.cpp:511
buf
#define buf
Definition
17.names.cpp:452
sync_calls
int sync_calls
Definition
27.ostream.unformatted.stdcxx-626.cpp:32
main
int main()
Definition
27.ostream.unformatted.stdcxx-626.cpp:43
assert
#define assert(expr)
Definition
_cassert.h:40
MyBuf
Definition
27.ostream.unformatted.stdcxx-626.cpp:35
MyBuf::sync
virtual int sync()
Definition
27.ostream.unformatted.stdcxx-626.cpp:36
Generated by
1.9.8