blob: 1d1cbc0826c08143bf78cd68b82f4c26e217037e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <istream>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_istream;
14
15// basic_istream(basic_istream&& rhs);
16
17#include <istream>
18#include <cassert>
19
Howard Hinnant73d21a42010-09-04 23:28:19 +000020#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021
22template <class CharT>
23struct testbuf
24 : public std::basic_streambuf<CharT>
25{
26 testbuf() {}
27};
28
29template <class CharT>
30struct test_istream
31 : public std::basic_istream<CharT>
32{
33 typedef std::basic_istream<CharT> base;
34 test_istream(testbuf<CharT>* sb) : base(sb) {}
35
36 test_istream(test_istream&& s)
37 : base(std::move(s)) {}
38};
39
Howard Hinnant73d21a42010-09-04 23:28:19 +000040#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000041
42int main()
43{
Howard Hinnant73d21a42010-09-04 23:28:19 +000044#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000045 {
46 testbuf<char> sb;
47 test_istream<char> is1(&sb);
48 test_istream<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_istream<wchar_t> is1(&sb);
64 test_istream<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 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000077#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000078}