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