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