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
10
11// XFAIL: FROZEN-CXX03-HEADERS-FIXME
12
13// <fstream>
14
15// template <class charT, class traits = char_traits<charT> >
16// class basic_ifstream
17
18// basic_ifstream(basic_ifstream&& rhs);
19
20#include <fstream>
21#include <cassert>
22#include <ios>
23
24#include "test_macros.h"
25#include "operator_hijacker.h"
26
27int main(int, char**)
28{
29 {
30 std::ifstream fso("test.dat");
31 std::ifstream fs = std::move(fso);
32 double x = 0;
33 fs >> x;
34 assert(x == 3.25);
35 }
36 {
37 std::basic_ifstream<char, operator_hijacker_char_traits<char> > fso("test.dat");
38 std::basic_ifstream<char, operator_hijacker_char_traits<char> > fs = std::move(fso);
39 std::basic_string<char, operator_hijacker_char_traits<char> > x;
40 fs >> x;
41 assert(x == "3.25");
42 }
43#ifndef TEST_HAS_NO_WIDE_CHARACTERS
44 {
45 std::wifstream fso("test.dat");
46 std::wifstream fs = std::move(fso);
47 double x = 0;
48 fs >> x;
49 assert(x == 3.25);
50 }
51 {
52 std::basic_ifstream<wchar_t, operator_hijacker_char_traits<wchar_t> > fso("test.dat");
53 std::basic_ifstream<wchar_t, operator_hijacker_char_traits<wchar_t> > fs = std::move(fso);
54 std::basic_string<wchar_t, operator_hijacker_char_traits<wchar_t> > x;
55 fs >> x;
56 assert(x == L"3.25");
57 }
58#endif
59
60 return 0;
61}
62

source code of libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp