1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <istream> 10 11 // template <class charT, class traits = char_traits<charT> > 12 // class basic_istream; 13 14 // basic_istream(basic_istream&& rhs); 15 16 #include <istream> 17 #include <cassert> 18 19 #include "test_macros.h" 20 21 template <class CharT> 22 struct testbuf 23 : public std::basic_streambuf<CharT> 24 { 25 testbuf() {} 26 }; 27 28 template <class CharT> 29 struct test_istream 30 : public std::basic_istream<CharT> 31 { 32 typedef std::basic_istream<CharT> base; 33 test_istream(testbuf<CharT>* sb) : base(sb) {} 34 35 test_istream(test_istream&& s) 36 : base(std::move(s)) {} 37 }; 38 39 int main(int, char**) 40 { 41 { 42 testbuf<char> sb; 43 test_istream<char> is1(&sb); 44 test_istream<char> is(std::move(is1)); 45 assert(is1.rdbuf() == &sb); 46 assert(is1.gcount() == 0); 47 assert(is.gcount() == 0); 48 assert(is.rdbuf() == 0); 49 assert(is.tie() == 0); 50 assert(is.fill() == ' '); 51 assert(is.rdstate() == is.goodbit); 52 assert(is.exceptions() == is.goodbit); 53 assert(is.flags() == (is.skipws | is.dec)); 54 assert(is.precision() == 6); 55 assert(is.getloc().name() == "C"); 56 } 57 { 58 testbuf<wchar_t> sb; 59 test_istream<wchar_t> is1(&sb); 60 test_istream<wchar_t> is(std::move(is1)); 61 assert(is1.gcount() == 0); 62 assert(is.gcount() == 0); 63 assert(is1.rdbuf() == &sb); 64 assert(is.rdbuf() == 0); 65 assert(is.tie() == 0); 66 assert(is.fill() == L' '); 67 assert(is.rdstate() == is.goodbit); 68 assert(is.exceptions() == is.goodbit); 69 assert(is.flags() == (is.skipws | is.dec)); 70 assert(is.precision() == 6); 71 assert(is.getloc().name() == "C"); 72 } 73 74 return 0; 75 } 76