//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template > // class basic_ostream; // basic_ostream& operator=(basic_ostream&& rhs); #include #include #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct testbuf : public std::basic_streambuf { testbuf() {} }; template struct test_ostream : public std::basic_ostream { typedef std::basic_ostream base; test_ostream(testbuf* sb) : base(sb) {} test_ostream& operator=(test_ostream&& s) {base::operator=(std::move(s)); return *this;} }; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { testbuf sb1; testbuf sb2; test_ostream os1(&sb1); test_ostream os2(&sb2); os2 = (std::move(os1)); assert(os1.rdbuf() == &sb1); assert(os1.tie() == 0); assert(os1.fill() == ' '); assert(os1.rdstate() == os1.goodbit); assert(os1.exceptions() == os1.goodbit); assert(os1.flags() == (os1.skipws | os1.dec)); assert(os1.precision() == 6); assert(os1.getloc().name() == "C"); assert(os2.rdbuf() == &sb2); assert(os2.tie() == 0); assert(os2.fill() == ' '); assert(os2.rdstate() == os2.goodbit); assert(os2.exceptions() == os2.goodbit); assert(os2.flags() == (os2.skipws | os2.dec)); assert(os2.precision() == 6); assert(os2.getloc().name() == "C"); } { testbuf sb1; testbuf sb2; test_ostream os1(&sb1); test_ostream os2(&sb2); os2 = (std::move(os1)); assert(os1.rdbuf() == &sb1); assert(os1.tie() == 0); assert(os1.fill() == ' '); assert(os1.rdstate() == os1.goodbit); assert(os1.exceptions() == os1.goodbit); assert(os1.flags() == (os1.skipws | os1.dec)); assert(os1.precision() == 6); assert(os1.getloc().name() == "C"); assert(os2.rdbuf() == &sb2); assert(os2.tie() == 0); assert(os2.fill() == ' '); assert(os2.rdstate() == os2.goodbit); assert(os2.exceptions() == os2.goodbit); assert(os2.flags() == (os2.skipws | os2.dec)); assert(os2.precision() == 6); assert(os2.getloc().name() == "C"); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }