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