• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <fstream>
11 
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_ifstream
14 
15 // explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
16 
17 #include <fstream>
18 #include <cassert>
19 
main()20 int main()
21 {
22     {
23         std::ifstream fs(std::string("test.dat"));
24         double x = 0;
25         fs >> x;
26         assert(x == 3.25);
27     }
28     // std::ifstream(const std::string&, std::ios_base::openmode) is tested in
29     // test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
30     // which creates writable files.
31     {
32         std::wifstream fs(std::string("test.dat"));
33         double x = 0;
34         fs >> x;
35         assert(x == 3.25);
36     }
37     // std::wifstream(const std::string&, std::ios_base::openmode) is tested in
38     // test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
39     // which creates writable files.
40 }
41