move_assign.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_ofstream
14
15// basic_ofstream& operator=(basic_ofstream&& rhs);
16
17#include <fstream>
18#include <cassert>
19
20int main()
21{
22#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
23    {
24        std::ofstream fso("test.dat");
25        std::ofstream fs;
26        fs = move(fso);
27        fs << 3.25;
28    }
29    {
30        std::ifstream fs("test.dat");
31        double x = 0;
32        fs >> x;
33        assert(x == 3.25);
34    }
35    remove("test.dat");
36    {
37        std::wofstream fso("test.dat");
38        std::wofstream fs;
39        fs = move(fso);
40        fs << 3.25;
41    }
42    {
43        std::wifstream fs("test.dat");
44        double x = 0;
45        fs >> x;
46        assert(x == 3.25);
47    }
48    remove("test.dat");
49#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
50}
51