blob: 94a55509ab88451c5f9a7ea2698fd24a4abbd006 [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& operator=(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& operator=(test_istream&& s)
37 {base::operator=(std::move(s)); return *this;}
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> sb1;
47 testbuf<char> sb2;
48 test_istream<char> is1(&sb1);
49 test_istream<char> is2(&sb2);
50 is2 = (std::move(is1));
51 assert(is1.rdbuf() == &sb1);
52 assert(is1.tie() == 0);
53 assert(is1.fill() == ' ');
54 assert(is1.rdstate() == is1.goodbit);
55 assert(is1.exceptions() == is1.goodbit);
56 assert(is1.flags() == (is1.skipws | is1.dec));
57 assert(is1.precision() == 6);
58 assert(is1.getloc().name() == "C");
59 assert(is2.rdbuf() == &sb2);
60 assert(is2.tie() == 0);
61 assert(is2.fill() == ' ');
62 assert(is2.rdstate() == is2.goodbit);
63 assert(is2.exceptions() == is2.goodbit);
64 assert(is2.flags() == (is2.skipws | is2.dec));
65 assert(is2.precision() == 6);
66 assert(is2.getloc().name() == "C");
67 }
68 {
69 testbuf<wchar_t> sb1;
70 testbuf<wchar_t> sb2;
71 test_istream<wchar_t> is1(&sb1);
72 test_istream<wchar_t> is2(&sb2);
73 is2 = (std::move(is1));
74 assert(is1.rdbuf() == &sb1);
75 assert(is1.tie() == 0);
76 assert(is1.fill() == ' ');
77 assert(is1.rdstate() == is1.goodbit);
78 assert(is1.exceptions() == is1.goodbit);
79 assert(is1.flags() == (is1.skipws | is1.dec));
80 assert(is1.precision() == 6);
81 assert(is1.getloc().name() == "C");
82 assert(is2.rdbuf() == &sb2);
83 assert(is2.tie() == 0);
84 assert(is2.fill() == ' ');
85 assert(is2.rdstate() == is2.goodbit);
86 assert(is2.exceptions() == is2.goodbit);
87 assert(is2.flags() == (is2.skipws | is2.dec));
88 assert(is2.precision() == 6);
89 assert(is2.getloc().name() == "C");
90 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000091#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000092}