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 // void close(); 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; 25 assert(!fs.is_open()); 26 fs.open(temp.c_str(), std::ios_base::out); 27 assert(fs.is_open()); 28 fs.close(); 29 assert(!fs.is_open()); 30 } 31 std::remove(temp.c_str()); 32 { 33 std::wfstream fs; 34 assert(!fs.is_open()); 35 fs.open(temp.c_str(), std::ios_base::out); 36 assert(fs.is_open()); 37 fs.close(); 38 assert(!fs.is_open()); 39 } 40 std::remove(temp.c_str()); 41 42 return 0; 43 } 44