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// <istream>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_iostream;
14
15// basic_iostream(basic_iostream&& rhs);
16
17#include <istream>
18#include <cassert>
19
20#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
21
22template <class CharT>
23struct testbuf
24    : public std::basic_streambuf<CharT>
25{
26    testbuf() {}
27};
28
29template <class CharT>
30struct 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#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
41
42int main()
43{
44#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
45    {
46        testbuf<char> sb;
47        test_iostream<char> is1(&sb);
48        test_iostream<char> is(std::move(is1));
49        assert(is1.rdbuf() == &sb);
50        assert(is1.gcount() == 0);
51        assert(is.gcount() == 0);
52        assert(is.rdbuf() == 0);
53        assert(is.tie() == 0);
54        assert(is.fill() == ' ');
55        assert(is.rdstate() == is.goodbit);
56        assert(is.exceptions() == is.goodbit);
57        assert(is.flags() == (is.skipws | is.dec));
58        assert(is.precision() == 6);
59        assert(is.getloc().name() == "C");
60    }
61    {
62        testbuf<wchar_t> sb;
63        test_iostream<wchar_t> is1(&sb);
64        test_iostream<wchar_t> is(std::move(is1));
65        assert(is1.gcount() == 0);
66        assert(is.gcount() == 0);
67        assert(is1.rdbuf() == &sb);
68        assert(is.rdbuf() == 0);
69        assert(is.tie() == 0);
70        assert(is.fill() == L' ');
71        assert(is.rdstate() == is.goodbit);
72        assert(is.exceptions() == is.goodbit);
73        assert(is.flags() == (is.skipws | is.dec));
74        assert(is.precision() == 6);
75        assert(is.getloc().name() == "C");
76    }
77#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
78}
79