1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant//                     The LLVM Compiler Infrastructure
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <istream>
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// template <class charT, class traits = char_traits<charT> >
13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// class basic_istream;
14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// void swap(basic_istream& rhs);
16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <istream>
18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert>
19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttemplate <class CharT>
21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantstruct testbuf
22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    : public std::basic_streambuf<CharT>
23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    testbuf() {}
25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant};
26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttemplate <class CharT>
28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantstruct test_istream
29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    : public std::basic_istream<CharT>
30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    typedef std::basic_istream<CharT> base;
32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test_istream(testbuf<CharT>* sb) : base(sb) {}
33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    void swap(test_istream& s) {base::swap(s);}
35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant};
36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main()
38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    {
40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        testbuf<char> sb1;
41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        testbuf<char> sb2;
42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        test_istream<char> is1(&sb1);
43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        test_istream<char> is2(&sb2);
44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        is1.swap(is2);
45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.rdbuf() == &sb1);
46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.tie() == 0);
47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.fill() == ' ');
48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.rdstate() == is1.goodbit);
49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.exceptions() == is1.goodbit);
50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.flags() == (is1.skipws | is1.dec));
51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.precision() == 6);
52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.getloc().name() == "C");
53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.rdbuf() == &sb2);
54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.tie() == 0);
55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.fill() == ' ');
56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.rdstate() == is2.goodbit);
57bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.exceptions() == is2.goodbit);
58bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.flags() == (is2.skipws | is2.dec));
59bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.precision() == 6);
60bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.getloc().name() == "C");
61bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    }
62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    {
63bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        testbuf<wchar_t> sb1;
64bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        testbuf<wchar_t> sb2;
65bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        test_istream<wchar_t> is1(&sb1);
66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        test_istream<wchar_t> is2(&sb2);
67bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        is1.swap(is2);
68bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.rdbuf() == &sb1);
69bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.tie() == 0);
70bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.fill() == ' ');
71bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.rdstate() == is1.goodbit);
72bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.exceptions() == is1.goodbit);
73bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.flags() == (is1.skipws | is1.dec));
74bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.precision() == 6);
75bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is1.getloc().name() == "C");
76bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.rdbuf() == &sb2);
77bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.tie() == 0);
78bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.fill() == ' ');
79bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.rdstate() == is2.goodbit);
80bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.exceptions() == is2.goodbit);
81bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.flags() == (is2.skipws | is2.dec));
82bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.precision() == 6);
83bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(is2.getloc().name() == "C");
84bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    }
85bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
86