move.pass.cpp revision 256813f4e7915d64776a4edd5f4765d893b9f062
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. 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#ifdef _LIBCPP_MOVE 21 22template <class CharT> 23struct testbuf 24 : public std::basic_streambuf<CharT> 25{ 26 testbuf() {} 27}; 28 29template <class CharT> 30struct test_ostream 31 : public std::basic_ostream<CharT> 32{ 33 typedef std::basic_ostream<CharT> base; 34 test_ostream(testbuf<CharT>* sb) : base(sb) {} 35 36 test_ostream(test_ostream&& s) 37 : base(std::move(s)) {} 38}; 39 40#endif // _LIBCPP_MOVE 41 42int main() 43{ 44#ifdef _LIBCPP_MOVE 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_MOVE 74} 75