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_ifstream 13 14 // explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); 15 16 #include <fstream> 17 #include <cassert> 18 19 int main(int, char**) 20 { 21 { 22 std::ifstream fs("test.dat"); 23 double x = 0; 24 fs >> x; 25 assert(x == 3.25); 26 } 27 // std::ifstream(const char*, std::ios_base::openmode) is tested in 28 // test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp 29 // which creates writable files. 30 { 31 std::wifstream fs("test.dat"); 32 double x = 0; 33 fs >> x; 34 assert(x == 3.25); 35 } 36 // std::wifstream(const char*, std::ios_base::openmode) is tested in 37 // test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp 38 // which creates writable files. 39 40 return 0; 41 } 42