From Jason Turner

[ifstream]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4yuasi8p/{from.md → to.md} +124 -9
tmp/tmp4yuasi8p/{from.md → to.md} RENAMED
@@ -1,38 +1,45 @@
1
- #### Class template `basic_ifstream` <a id="ifstream">[[ifstream]]</a>
2
 
3
  ``` cpp
4
  namespace std {
5
  template <class charT, class traits = char_traits<charT>>
6
  class basic_ifstream : public basic_istream<charT, traits> {
7
  public:
8
- typedef charT char_type;
9
- typedef typename traits::int_type int_type;
10
- typedef typename traits::pos_type pos_type;
11
- typedef typename traits::off_type off_type;
12
- typedef traits traits_type;
13
 
14
- // [ifstream.cons] Constructors:
15
  basic_ifstream();
16
  explicit basic_ifstream(const char* s,
17
  ios_base::openmode mode = ios_base::in);
 
 
18
  explicit basic_ifstream(const string& s,
19
  ios_base::openmode mode = ios_base::in);
 
 
20
  basic_ifstream(const basic_ifstream& rhs) = delete;
21
  basic_ifstream(basic_ifstream&& rhs);
22
 
23
- // [ifstream.assign] Assign/swap:
24
  basic_ifstream& operator=(const basic_ifstream& rhs) = delete;
25
  basic_ifstream& operator=(basic_ifstream&& rhs);
26
  void swap(basic_ifstream& rhs);
27
 
28
- // [ifstream.members] Members:
29
  basic_filebuf<charT, traits>* rdbuf() const;
30
 
31
  bool is_open() const;
32
  void open(const char* s, ios_base::openmode mode = ios_base::in);
 
 
33
  void open(const string& s, ios_base::openmode mode = ios_base::in);
 
34
  void close();
35
  private:
36
  basic_filebuf<charT, traits> sb; // exposition only
37
  };
38
 
@@ -47,5 +54,113 @@ files. It uses a `basic_filebuf<{}charT, traits>` object to control the
47
  associated sequence. For the sake of exposition, the maintained data is
48
  presented here as:
49
 
50
  - `sb`, the `filebuf` object.
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Class template `basic_ifstream` <a id="ifstream">[[ifstream]]</a>
2
 
3
  ``` cpp
4
  namespace std {
5
  template <class charT, class traits = char_traits<charT>>
6
  class basic_ifstream : public basic_istream<charT, traits> {
7
  public:
8
+ using char_type = charT;
9
+ using int_type = typename traits::int_type;
10
+ using pos_type = typename traits::pos_type;
11
+ using off_type = typename traits::off_type;
12
+ using traits_type = traits;
13
 
14
+ // [ifstream.cons], constructors
15
  basic_ifstream();
16
  explicit basic_ifstream(const char* s,
17
  ios_base::openmode mode = ios_base::in);
18
+ explicit basic_ifstream(const filesystem::path::value_type* s,
19
+ ios_base::openmode mode = ios_base::in); // wide systems only; see [fstream.syn]
20
  explicit basic_ifstream(const string& s,
21
  ios_base::openmode mode = ios_base::in);
22
+ explicit basic_ifstream(const filesystem::path& s,
23
+ ios_base::openmode mode = ios_base::in);
24
  basic_ifstream(const basic_ifstream& rhs) = delete;
25
  basic_ifstream(basic_ifstream&& rhs);
26
 
27
+ // [ifstream.assign], assign and swap
28
  basic_ifstream& operator=(const basic_ifstream& rhs) = delete;
29
  basic_ifstream& operator=(basic_ifstream&& rhs);
30
  void swap(basic_ifstream& rhs);
31
 
32
+ // [ifstream.members], members
33
  basic_filebuf<charT, traits>* rdbuf() const;
34
 
35
  bool is_open() const;
36
  void open(const char* s, ios_base::openmode mode = ios_base::in);
37
+ void open(const filesystem::path::value_type* s,
38
+ ios_base::openmode mode = ios_base::in); // wide systems only; see [fstream.syn]
39
  void open(const string& s, ios_base::openmode mode = ios_base::in);
40
+ void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in);
41
  void close();
42
  private:
43
  basic_filebuf<charT, traits> sb; // exposition only
44
  };
45
 
 
54
  associated sequence. For the sake of exposition, the maintained data is
55
  presented here as:
56
 
57
  - `sb`, the `filebuf` object.
58
 
59
+ #### `basic_ifstream` constructors <a id="ifstream.cons">[[ifstream.cons]]</a>
60
+
61
+ ``` cpp
62
+ basic_ifstream();
63
+ ```
64
+
65
+ *Effects:* Constructs an object of class
66
+ `basic_ifstream<charT, traits>`, initializing the base class with
67
+ `basic_istream(&sb)` and initializing `sb` with
68
+ `basic_filebuf<charT, traits>())` ([[istream.cons]], [[filebuf.cons]]).
69
+
70
+ ``` cpp
71
+ explicit basic_ifstream(const char* s,
72
+ ios_base::openmode mode = ios_base::in);
73
+ explicit basic_ifstream(const filesystem::path::value_type* s,
74
+ ios_base::openmode mode = ios_base::in); // wide systems only; see [fstream.syn]
75
+ ```
76
+
77
+ *Effects:* Constructs an object of class `basic_ifstream`, initializing
78
+ the base class with `basic_istream(&sb)` and initializing `sb` with
79
+ `basic_filebuf<charT, traits>())` ([[istream.cons]], [[filebuf.cons]]),
80
+ then calls `rdbuf()->open(s, mode | ios_base::in)`. If that function
81
+ returns a null pointer, calls `setstate(failbit)`.
82
+
83
+ ``` cpp
84
+ explicit basic_ifstream(const string& s,
85
+ ios_base::openmode mode = ios_base::in);
86
+ explicit basic_ifstream(const filesystem::path& s,
87
+ ios_base::openmode mode = ios_base::in);
88
+ ```
89
+
90
+ *Effects:* The same as `basic_ifstream(s.c_str(), mode)`.
91
+
92
+ ``` cpp
93
+ basic_ifstream(basic_ifstream&& rhs);
94
+ ```
95
+
96
+ *Effects:* Move constructs from the rvalue `rhs`. This is accomplished
97
+ by move constructing the base class, and the contained `basic_filebuf`.
98
+ Next `basic_istream<charT, traits>::set_rdbuf(&sb)` is called to install
99
+ the contained `basic_filebuf`.
100
+
101
+ #### Assign and swap <a id="ifstream.assign">[[ifstream.assign]]</a>
102
+
103
+ ``` cpp
104
+ basic_ifstream& operator=(basic_ifstream&& rhs);
105
+ ```
106
+
107
+ *Effects:* Move assigns the base and members of `*this` from the base
108
+ and corresponding members of `rhs`.
109
+
110
+ *Returns:* `*this`.
111
+
112
+ ``` cpp
113
+ void swap(basic_ifstream& rhs);
114
+ ```
115
+
116
+ *Effects:* Exchanges the state of `*this` and `rhs` by calling
117
+ `basic_istream<charT, traits>::swap(rhs)` and `sb.swap(rhs.sb)`.
118
+
119
+ ``` cpp
120
+ template <class charT, class traits>
121
+ void swap(basic_ifstream<charT, traits>& x,
122
+ basic_ifstream<charT, traits>& y);
123
+ ```
124
+
125
+ *Effects:* As if by `x.swap(y)`.
126
+
127
+ #### Member functions <a id="ifstream.members">[[ifstream.members]]</a>
128
+
129
+ ``` cpp
130
+ basic_filebuf<charT, traits>* rdbuf() const;
131
+ ```
132
+
133
+ *Returns:* `const_cast<basic_filebuf<charT, traits>*>(&sb)`.
134
+
135
+ ``` cpp
136
+ bool is_open() const;
137
+ ```
138
+
139
+ *Returns:* `rdbuf()->is_open()`.
140
+
141
+ ``` cpp
142
+ void open(const char* s, ios_base::openmode mode = ios_base::in);
143
+ void open(const filesystem::path::value_type* s,
144
+ ios_base::openmode mode = ios_base::in); // wide systems only; see [fstream.syn]
145
+ ```
146
+
147
+ *Effects:* Calls `rdbuf()->open(s, mode | ios_base::in)`. If that
148
+ function does not return a null pointer calls `clear()`, otherwise calls
149
+ `setstate(failbit)` (which may throw `ios_base::failure`)
150
+ ([[iostate.flags]]).
151
+
152
+ ``` cpp
153
+ void open(const string& s, ios_base::openmode mode = ios_base::in);
154
+ void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in);
155
+ ```
156
+
157
+ *Effects:* Calls `open(s.c_str(), mode)`.
158
+
159
+ ``` cpp
160
+ void close();
161
+ ```
162
+
163
+ *Effects:* Calls `rdbuf()->close()` and, if that function returns a null
164
+ pointer, calls `setstate(failbit)` (which may throw
165
+ `ios_base::failure`) ([[iostate.flags]]).
166
+