member_swap.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// void swap(basic_ifstream& rhs); 16 17#include <fstream> 18#include <cassert> 19 20int main() 21{ 22 { 23 std::ifstream fs1("test.dat"); 24 std::ifstream fs2("test2.dat"); 25 fs1.swap(fs2); 26 double x = 0; 27 fs1 >> x; 28 assert(x == 4.5); 29 fs2 >> x; 30 assert(x == 3.25); 31 } 32 { 33 std::wifstream fs1("test.dat"); 34 std::wifstream fs2("test2.dat"); 35 fs1.swap(fs2); 36 double x = 0; 37 fs1 >> x; 38 assert(x == 4.5); 39 fs2 >> x; 40 assert(x == 3.25); 41 } 42} 43