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_istream; 16 17// basic_istream(basic_istream&& rhs); 18 19#include <istream> 20#include <cassert> 21 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 40int main() 41{ 42 { 43 testbuf<char> sb; 44 test_istream<char> is1(&sb); 45 test_istream<char> is(std::move(is1)); 46 assert(is1.rdbuf() == &sb); 47 assert(is1.gcount() == 0); 48 assert(is.gcount() == 0); 49 assert(is.rdbuf() == 0); 50 assert(is.tie() == 0); 51 assert(is.fill() == ' '); 52 assert(is.rdstate() == is.goodbit); 53 assert(is.exceptions() == is.goodbit); 54 assert(is.flags() == (is.skipws | is.dec)); 55 assert(is.precision() == 6); 56 assert(is.getloc().name() == "C"); 57 } 58 { 59 testbuf<wchar_t> sb; 60 test_istream<wchar_t> is1(&sb); 61 test_istream<wchar_t> is(std::move(is1)); 62 assert(is1.gcount() == 0); 63 assert(is.gcount() == 0); 64 assert(is1.rdbuf() == &sb); 65 assert(is.rdbuf() == 0); 66 assert(is.tie() == 0); 67 assert(is.fill() == L' '); 68 assert(is.rdstate() == is.goodbit); 69 assert(is.exceptions() == is.goodbit); 70 assert(is.flags() == (is.skipws | is.dec)); 71 assert(is.precision() == 6); 72 assert(is.getloc().name() == "C"); 73 } 74} 75