//===----------------------------------------------------------------------===// // // 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_istream; // void swap(basic_istream& rhs); #include #include template struct testbuf : public std::basic_streambuf { testbuf() {} }; template struct test_istream : public std::basic_istream { typedef std::basic_istream base; test_istream(testbuf* sb) : base(sb) {} void swap(test_istream& s) {base::swap(s);} }; int main() { { testbuf sb1; testbuf sb2; test_istream is1(&sb1); test_istream is2(&sb2); is1.swap(is2); 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"); } { testbuf sb1; testbuf sb2; test_istream is1(&sb1); test_istream is2(&sb2); is1.swap(is2); 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"); } }