• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: c++98, c++03
11 
12 // <ostream>
13 
14 // template <class charT, class traits = char_traits<charT> >
15 // class basic_ostream;
16 
17 // basic_ostream& operator=(basic_ostream&& rhs);
18 
19 #include <ostream>
20 #include <cassert>
21 
22 
23 template <class CharT>
24 struct testbuf
25     : public std::basic_streambuf<CharT>
26 {
testbuftestbuf27     testbuf() {}
28 };
29 
30 template <class CharT>
31 struct test_ostream
32     : public std::basic_ostream<CharT>
33 {
34     typedef std::basic_ostream<CharT> base;
test_ostreamtest_ostream35     test_ostream(testbuf<CharT>* sb) : base(sb) {}
36 
operator =test_ostream37     test_ostream& operator=(test_ostream&& s)
38         {base::operator=(std::move(s)); return *this;}
39 };
40 
41 
main()42 int main()
43 {
44     {
45         testbuf<char> sb1;
46         testbuf<char> sb2;
47         test_ostream<char> os1(&sb1);
48         test_ostream<char> os2(&sb2);
49         os2 = (std::move(os1));
50         assert(os1.rdbuf() == &sb1);
51         assert(os1.tie() == 0);
52         assert(os1.fill() == ' ');
53         assert(os1.rdstate() == os1.goodbit);
54         assert(os1.exceptions() == os1.goodbit);
55         assert(os1.flags() == (os1.skipws | os1.dec));
56         assert(os1.precision() == 6);
57         assert(os1.getloc().name() == "C");
58         assert(os2.rdbuf() == &sb2);
59         assert(os2.tie() == 0);
60         assert(os2.fill() == ' ');
61         assert(os2.rdstate() == os2.goodbit);
62         assert(os2.exceptions() == os2.goodbit);
63         assert(os2.flags() == (os2.skipws | os2.dec));
64         assert(os2.precision() == 6);
65         assert(os2.getloc().name() == "C");
66     }
67     {
68         testbuf<wchar_t> sb1;
69         testbuf<wchar_t> sb2;
70         test_ostream<wchar_t> os1(&sb1);
71         test_ostream<wchar_t> os2(&sb2);
72         os2 = (std::move(os1));
73         assert(os1.rdbuf() == &sb1);
74         assert(os1.tie() == 0);
75         assert(os1.fill() == ' ');
76         assert(os1.rdstate() == os1.goodbit);
77         assert(os1.exceptions() == os1.goodbit);
78         assert(os1.flags() == (os1.skipws | os1.dec));
79         assert(os1.precision() == 6);
80         assert(os1.getloc().name() == "C");
81         assert(os2.rdbuf() == &sb2);
82         assert(os2.tie() == 0);
83         assert(os2.fill() == ' ');
84         assert(os2.rdstate() == os2.goodbit);
85         assert(os2.exceptions() == os2.goodbit);
86         assert(os2.flags() == (os2.skipws | os2.dec));
87         assert(os2.precision() == 6);
88         assert(os2.getloc().name() == "C");
89     }
90 }
91