//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template > // class basic_iostream; // basic_iostream& operator=(basic_iostream&& rhs); #include #include #include #include "test_macros.h" template struct testbuf : public std::basic_streambuf { testbuf() {} }; template struct test_iostream : public std::basic_iostream { typedef std::basic_iostream base; test_iostream(testbuf* sb) : base(sb) {} test_iostream& operator=(test_iostream&& s) {base::operator=(std::move(s)); return *this;} }; int main(int, char**) { { testbuf sb1; testbuf sb2; test_iostream is1(&sb1); test_iostream is2(&sb2); is2 = (std::move(is1)); assert(is1.rdbuf() == &sb1); assert(is1.tie() == 0); assert(is1.fill() == ' '); assert(is1.rdstate() == is1.goodbit); assert(is1.exceptions() == is1.goodbit); assert(is1.flags() == (is1.skipws | is1.dec)); assert(is1.precision() == 6); assert(is1.getloc().name() == "C"); assert(is2.rdbuf() == &sb2); assert(is2.tie() == 0); assert(is2.fill() == ' '); assert(is2.rdstate() == is2.goodbit); assert(is2.exceptions() == is2.goodbit); assert(is2.flags() == (is2.skipws | is2.dec)); assert(is2.precision() == 6); assert(is2.getloc().name() == "C"); } #ifndef TEST_HAS_NO_WIDE_CHARACTERS { testbuf sb1; testbuf sb2; test_iostream is1(&sb1); test_iostream is2(&sb2); is2 = (std::move(is1)); assert(is1.rdbuf() == &sb1); assert(is1.tie() == 0); assert(is1.fill() == ' '); assert(is1.rdstate() == is1.goodbit); assert(is1.exceptions() == is1.goodbit); assert(is1.flags() == (is1.skipws | is1.dec)); assert(is1.precision() == 6); assert(is1.getloc().name() == "C"); assert(is2.rdbuf() == &sb2); assert(is2.tie() == 0); assert(is2.fill() == ' '); assert(is2.rdstate() == is2.goodbit); assert(is2.exceptions() == is2.goodbit); assert(is2.flags() == (is2.skipws | is2.dec)); assert(is2.precision() == 6); assert(is2.getloc().name() == "C"); } #endif return 0; }