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 wchar_t* s, ios_base::openmode mode = ios_base::in | ios_base::out); 15 16 // This extension is only provided on Windows. 17 // REQUIRES: windows 18 // UNSUPPORTED: no-wide-characters 19 20 // TODO: This should not be necessary 21 // ADDITIONAL_COMPILE_FLAGS:-D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT 22 23 #include <fstream> 24 #include <cassert> 25 #include "test_macros.h" 26 #include "wide_temp_file.h" 27 main(int,char **)28int main(int, char**) { 29 std::wstring temp = get_wide_temp_file_name(); 30 { 31 std::fstream fs(temp.c_str(), 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 _wremove(temp.c_str()); 40 { 41 std::wfstream fs(temp.c_str(), 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 _wremove(temp.c_str()); 50 51 return 0; 52 } 53