1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // FILE_DEPENDENCIES: test.dat, test2.dat
10 
11 // <fstream>
12 
13 // template <class charT, class traits = char_traits<charT> >
14 // class basic_ifstream
15 
16 // void swap(basic_ifstream& rhs);
17 
18 #include <fstream>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
main(int,char **)23 int main(int, char**)
24 {
25     {
26         std::ifstream fs1("test.dat");
27         std::ifstream fs2("test2.dat");
28         fs1.swap(fs2);
29         double x = 0;
30         fs1 >> x;
31         assert(x == 4.5);
32         fs2 >> x;
33         assert(x == 3.25);
34     }
35     {
36         std::wifstream fs1("test.dat");
37         std::wifstream fs2("test2.dat");
38         fs1.swap(fs2);
39         double x = 0;
40         fs1 >> x;
41         assert(x == 4.5);
42         fs2 >> x;
43         assert(x == 3.25);
44     }
45 
46   return 0;
47 }
48