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 // <fstream>
10 
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_fstream
13 
14 // explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
15 
16 #include <fstream>
17 #include <cassert>
18 #include "platform_support.h"
19 
20 int main(int, char**)
21 {
22     std::string temp = get_temp_file_name();
23     {
24         std::fstream fs(temp,
25                         std::ios_base::in | std::ios_base::out
26                                           | std::ios_base::trunc);
27         double x = 0;
28         fs << 3.25;
29         fs.seekg(0);
30         fs >> x;
31         assert(x == 3.25);
32     }
33     std::remove(temp.c_str());
34     {
35         std::wfstream fs(temp,
36                          std::ios_base::in | std::ios_base::out
37                                            | std::ios_base::trunc);
38         double x = 0;
39         fs << 3.25;
40         fs.seekg(0);
41         fs >> x;
42         assert(x == 3.25);
43     }
44     std::remove(temp.c_str());
45 
46   return 0;
47 }
48