1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <ostream>
11 
12 // template <class charT, class traits = char_traits<charT> >
13 //   class basic_ostream;
14 
15 // template <class charT, class traits>
16 //   basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
17 
18 #include <ostream>
19 #include <cassert>
20 
21 int sync_called = 0;
22 
23 template <class CharT>
24 class testbuf
25     : public std::basic_streambuf<CharT>
26 {
27 public:
testbuf()28     testbuf()
29     {
30     }
31 
32 protected:
33 
34     virtual int
sync()35         sync()
36         {
37             ++sync_called;
38             return 0;
39         }
40 };
41 
main()42 int main()
43 {
44     {
45         testbuf<char> sb;
46         std::ostream os(&sb);
47         flush(os);
48         assert(sync_called == 1);
49         assert(os.good());
50     }
51     {
52         testbuf<wchar_t> sb;
53         std::wostream os(&sb);
54         flush(os);
55         assert(sync_called == 2);
56         assert(os.good());
57     }
58 }
59