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