1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <istream>
10 
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_iostream;
13 
14 // basic_iostream(basic_iostream&& rhs);
15 
16 #include <istream>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
21 
22 template <class CharT>
23 struct testbuf
24     : public std::basic_streambuf<CharT>
25 {
26     testbuf() {}
27 };
28 
29 template <class CharT>
30 struct test_iostream
31     : public std::basic_iostream<CharT>
32 {
33     typedef std::basic_iostream<CharT> base;
34     test_iostream(testbuf<CharT>* sb) : base(sb) {}
35 
36     test_iostream(test_iostream&& s)
37         : base(std::move(s)) {}
38 };
39 
40 
41 int main(int, char**)
42 {
43     {
44         testbuf<char> sb;
45         test_iostream<char> is1(&sb);
46         test_iostream<char> is(std::move(is1));
47         assert(is1.rdbuf() == &sb);
48         assert(is1.gcount() == 0);
49         assert(is.gcount() == 0);
50         assert(is.rdbuf() == 0);
51         assert(is.tie() == 0);
52         assert(is.fill() == ' ');
53         assert(is.rdstate() == is.goodbit);
54         assert(is.exceptions() == is.goodbit);
55         assert(is.flags() == (is.skipws | is.dec));
56         assert(is.precision() == 6);
57         assert(is.getloc().name() == "C");
58     }
59     {
60         testbuf<wchar_t> sb;
61         test_iostream<wchar_t> is1(&sb);
62         test_iostream<wchar_t> is(std::move(is1));
63         assert(is1.gcount() == 0);
64         assert(is.gcount() == 0);
65         assert(is1.rdbuf() == &sb);
66         assert(is.rdbuf() == 0);
67         assert(is.tie() == 0);
68         assert(is.fill() == L' ');
69         assert(is.rdstate() == is.goodbit);
70         assert(is.exceptions() == is.goodbit);
71         assert(is.flags() == (is.skipws | is.dec));
72         assert(is.precision() == 6);
73         assert(is.getloc().name() == "C");
74     }
75 
76   return 0;
77 }
78