//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template > // class basic_ostream; // void swap(basic_ostream& rhs); #include #include 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) {} void swap(test_ostream& s) {base::swap(s);} }; int main() { { testbuf sb1; testbuf sb2; test_ostream os1(&sb1); test_ostream os2(&sb2); os1.swap(os2); 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); os1.swap(os2); 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"); } }