1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <fstream>
11 
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_ifstream
14 
15 // template <class charT, class traits>
16 //   void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
17 
18 #include <fstream>
19 #include <cassert>
20 
main()21 int main()
22 {
23     {
24         std::ifstream fs1("test.dat");
25         std::ifstream fs2("test2.dat");
26         swap(fs1, fs2);
27         double x = 0;
28         fs1 >> x;
29         assert(x == 4.5);
30         fs2 >> x;
31         assert(x == 3.25);
32     }
33     {
34         std::wifstream fs1("test.dat");
35         std::wifstream fs2("test2.dat");
36         swap(fs1, fs2);
37         double x = 0;
38         fs1 >> x;
39         assert(x == 4.5);
40         fs2 >> x;
41         assert(x == 3.25);
42     }
43 }
44