From Jason Turner

[filebuf]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_n61vf3s/{from.md → to.md} +40 -37
tmp/tmp_n61vf3s/{from.md → to.md} RENAMED
@@ -1,7 +1,9 @@
1
  ### Class template `basic_filebuf` <a id="filebuf">[[filebuf]]</a>
2
 
 
 
3
  ``` cpp
4
  namespace std {
5
  template<class charT, class traits = char_traits<charT>>
6
  class basic_filebuf : public basic_streambuf<charT, traits> {
7
  public:
@@ -15,11 +17,11 @@ namespace std {
15
  basic_filebuf();
16
  basic_filebuf(const basic_filebuf&) = delete;
17
  basic_filebuf(basic_filebuf&& rhs);
18
  virtual ~basic_filebuf();
19
 
20
- // [filebuf.assign], assign and swap
21
  basic_filebuf& operator=(const basic_filebuf&) = delete;
22
  basic_filebuf& operator=(basic_filebuf&& rhs);
23
  void swap(basic_filebuf& rhs);
24
 
25
  // [filebuf.members], members
@@ -50,14 +52,10 @@ namespace std {
50
  ios_base::openmode which
51
  = ios_base::in | ios_base::out) override;
52
  int sync() override;
53
  void imbue(const locale& loc) override;
54
  };
55
-
56
- template<class charT, class traits>
57
- void swap(basic_filebuf<charT, traits>& x,
58
- basic_filebuf<charT, traits>& y);
59
  }
60
  ```
61
 
62
  The class `basic_filebuf<charT, traits>` associates both the input
63
  sequence and the output sequence with a file.
@@ -155,12 +153,11 @@ void swap(basic_filebuf& rhs);
155
 
156
  *Effects:* Exchanges the state of `*this` and `rhs`.
157
 
158
  ``` cpp
159
  template<class charT, class traits>
160
- void swap(basic_filebuf<charT, traits>& x,
161
- basic_filebuf<charT, traits>& y);
162
  ```
163
 
164
  *Effects:* Equivalent to: `x.swap(y)`.
165
 
166
  #### Member functions <a id="filebuf.members">[[filebuf.members]]</a>
@@ -187,35 +184,42 @@ argument determined from `mode & ~ios_base::ate` as indicated in
187
  [[filebuf.open.modes]]. If `mode` is not some combination of flags shown
188
  in the table then the open fails.
189
 
190
  **Table: File open modes** <a id="filebuf.open.modes">[filebuf.open.modes]</a>
191
 
192
- | `binary` | `in` | `out` | `trunc` | `app` | | `stdio` equivalent |
193
- | -------- | ---- | ----- | ------- | ----- | --- | ------------------ |
194
- | | | + | | | `"w"` |
195
- | | | + | | + | `"a"` |
196
- | | | | | + | `"a"` |
197
- | | | + | + | | `"w"` |
198
- | | + | | | | `"r"` |
199
- | | + | + | | | `"r+"` |
200
- | | + | + | + | | `"w+"` |
201
- | | + | + | | + | `"a+"` |
202
- | | + | | | + | `"a+"` + | | + | | | `"wb"` |
203
- | + | | + | | + | `"ab"` |
204
- | + | | | | + | `"ab"` |
205
- | + | | + | + | | `"wb"` |
206
- | + | + | | | | `"rb"` |
207
- | + | + | + | | | `"r+b"` |
208
- | + | + | + | + | | `"w+b"` |
209
- | + | + | + | | + | `"a+b"` |
210
- | + | + | | | + | `"a+b"` |
 
 
 
 
 
 
 
211
 
212
 
213
  If the open operation succeeds and `ios_base::ate` is set in `mode`,
214
  positions the file to the end (as if by calling
215
  `fseek(file, 0, SEEK_END)`, where `file` is the pointer returned by
216
- calling `fopen`). [^40]
217
 
218
  If the repositioning operation fails, calls `close()` and returns a null
219
  pointer to indicate failure.
220
 
221
  *Returns:* `this` if successful, a null pointer otherwise.
@@ -242,25 +246,25 @@ or throws an exception, the function closes the file (as if by calling
242
  `fclose(file)`). If any of the calls made by the function, including
243
  `fclose`, fails, `close` fails by returning a null pointer. If one of
244
  these calls throws an exception, the exception is caught and rethrown
245
  after closing the file.
246
 
 
 
247
  *Returns:* `this` on success, a null pointer otherwise.
248
 
249
- *Ensures:* `is_open() == false`.
250
-
251
  #### Overridden virtual functions <a id="filebuf.virtuals">[[filebuf.virtuals]]</a>
252
 
253
  ``` cpp
254
  streamsize showmanyc() override;
255
  ```
256
 
257
  *Effects:* Behaves the same as `basic_streambuf::showmanyc()`
258
  [[streambuf.virtuals]].
259
 
260
- *Remarks:* An implementation might well provide an overriding definition
261
- for this function signature if it can determine that more characters can
262
  be read from the input sequence.
263
 
264
  ``` cpp
265
  int_type underflow() override;
266
  ```
@@ -382,10 +386,15 @@ operation fails. Otherwise, if `way != basic_ios::cur` or `off != 0`,
382
  and if the last operation was output, then update the output sequence
383
  and write any unshift sequence. Next, seek to the new position: if
384
  `width > 0`, call `fseek(file, width * off, whence)`, otherwise call
385
  `fseek(file, 0, whence)`.
386
 
 
 
 
 
 
387
  *Remarks:* “The last operation was output” means either the last virtual
388
  operation was overflow or the put buffer is non-empty. “Write any
389
  unshift sequence” means, if `width` if less than zero then call
390
  `a_codecvt.unshift(state, xbuf, xbuf+XSIZE, xbuf_end)` and output the
391
  resulting unshift sequence. The function determines one of three values
@@ -398,16 +407,10 @@ for the argument `whence`, of type `int`, as indicated in
398
  | ---------------- | ------------------ |
399
  | `basic_ios::beg` | `SEEK_SET` |
400
  | `basic_ios::cur` | `SEEK_CUR` |
401
  | `basic_ios::end` | `SEEK_END` |
402
 
403
-
404
- *Returns:* A newly constructed `pos_type` object that stores the
405
- resultant stream position, if possible. If the positioning operation
406
- fails, or if the object cannot represent the resultant stream position,
407
- returns `pos_type(off_type(-1))`.
408
-
409
  ``` cpp
410
  pos_type seekpos(pos_type sp,
411
  ios_base::openmode which
412
  = ios_base::in | ios_base::out) override;
413
  ```
 
1
  ### Class template `basic_filebuf` <a id="filebuf">[[filebuf]]</a>
2
 
3
+ #### General <a id="filebuf.general">[[filebuf.general]]</a>
4
+
5
  ``` cpp
6
  namespace std {
7
  template<class charT, class traits = char_traits<charT>>
8
  class basic_filebuf : public basic_streambuf<charT, traits> {
9
  public:
 
17
  basic_filebuf();
18
  basic_filebuf(const basic_filebuf&) = delete;
19
  basic_filebuf(basic_filebuf&& rhs);
20
  virtual ~basic_filebuf();
21
 
22
+ // [filebuf.assign], assignment and swap
23
  basic_filebuf& operator=(const basic_filebuf&) = delete;
24
  basic_filebuf& operator=(basic_filebuf&& rhs);
25
  void swap(basic_filebuf& rhs);
26
 
27
  // [filebuf.members], members
 
52
  ios_base::openmode which
53
  = ios_base::in | ios_base::out) override;
54
  int sync() override;
55
  void imbue(const locale& loc) override;
56
  };
 
 
 
 
57
  }
58
  ```
59
 
60
  The class `basic_filebuf<charT, traits>` associates both the input
61
  sequence and the output sequence with a file.
 
153
 
154
  *Effects:* Exchanges the state of `*this` and `rhs`.
155
 
156
  ``` cpp
157
  template<class charT, class traits>
158
+ void swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
 
159
  ```
160
 
161
  *Effects:* Equivalent to: `x.swap(y)`.
162
 
163
  #### Member functions <a id="filebuf.members">[[filebuf.members]]</a>
 
184
  [[filebuf.open.modes]]. If `mode` is not some combination of flags shown
185
  in the table then the open fails.
186
 
187
  **Table: File open modes** <a id="filebuf.open.modes">[filebuf.open.modes]</a>
188
 
189
+ | `binary` | `in` | `out` | `trunc` | `app` | `noreplace` | `stdio` equivalent |
190
+ | -------- | ---- | ----- | ------- | ----- | ----------- | ------------------ |
191
+ | | | + | | | | `"w"` |
192
+ | | | + | | | + | `"wx"` |
193
+ | | | + | + | | | `"w"` |
194
+ | | | + | + | | + | `"wx"` |
195
+ | | | + | | + | | `"a"` |
196
+ | | | | | + | | `"a"` |
197
+ | | + | | | | | `"r"` |
198
+ | | + | + | | | | `"r+"` |
199
+ | | + | + | + | | | `"w+"` |
200
+ | | + | + | + | | + | `"w+x"` |
201
+ | | + | + | | + | | `"a+"` |
202
+ | | + | | | + | | `"a+"` |
203
+ | + | | + | | | | `"wb"` |
204
+ | + | | + | | | + | `"wbx"` |
205
+ | + | | + | + | | | `"wb"` |
206
+ | + | | + | + | | + | `"wbx"` |
207
+ | + | | + | | + | | `"ab"` |
208
+ | + | | | | + | | `"ab"` |
209
+ | + | + | | | | | `"rb"` |
210
+ | + | + | + | | | | `"r+b"` |
211
+ | + | + | + | + | | | `"w+b"` |
212
+ | + | + | + | + | | + | `"w+bx"` |
213
+ | + | + | + | | + | | `"a+b"` |
214
+ | + | + | | | + | | `"a+b"` |
215
 
216
 
217
  If the open operation succeeds and `ios_base::ate` is set in `mode`,
218
  positions the file to the end (as if by calling
219
  `fseek(file, 0, SEEK_END)`, where `file` is the pointer returned by
220
+ calling `fopen`).[^38]
221
 
222
  If the repositioning operation fails, calls `close()` and returns a null
223
  pointer to indicate failure.
224
 
225
  *Returns:* `this` if successful, a null pointer otherwise.
 
246
  `fclose(file)`). If any of the calls made by the function, including
247
  `fclose`, fails, `close` fails by returning a null pointer. If one of
248
  these calls throws an exception, the exception is caught and rethrown
249
  after closing the file.
250
 
251
+ *Ensures:* `is_open() == false`.
252
+
253
  *Returns:* `this` on success, a null pointer otherwise.
254
 
 
 
255
  #### Overridden virtual functions <a id="filebuf.virtuals">[[filebuf.virtuals]]</a>
256
 
257
  ``` cpp
258
  streamsize showmanyc() override;
259
  ```
260
 
261
  *Effects:* Behaves the same as `basic_streambuf::showmanyc()`
262
  [[streambuf.virtuals]].
263
 
264
+ *Remarks:* An implementation may provide an overriding definition for
265
+ this function signature if it can determine whether more characters can
266
  be read from the input sequence.
267
 
268
  ``` cpp
269
  int_type underflow() override;
270
  ```
 
386
  and if the last operation was output, then update the output sequence
387
  and write any unshift sequence. Next, seek to the new position: if
388
  `width > 0`, call `fseek(file, width * off, whence)`, otherwise call
389
  `fseek(file, 0, whence)`.
390
 
391
+ *Returns:* A newly constructed `pos_type` object that stores the
392
+ resultant stream position, if possible. If the positioning operation
393
+ fails, or if the object cannot represent the resultant stream position,
394
+ returns `pos_type(off_type(-1))`.
395
+
396
  *Remarks:* “The last operation was output” means either the last virtual
397
  operation was overflow or the put buffer is non-empty. “Write any
398
  unshift sequence” means, if `width` if less than zero then call
399
  `a_codecvt.unshift(state, xbuf, xbuf+XSIZE, xbuf_end)` and output the
400
  resulting unshift sequence. The function determines one of three values
 
407
  | ---------------- | ------------------ |
408
  | `basic_ios::beg` | `SEEK_SET` |
409
  | `basic_ios::cur` | `SEEK_CUR` |
410
  | `basic_ios::end` | `SEEK_END` |
411
 
 
 
 
 
 
 
412
  ``` cpp
413
  pos_type seekpos(pos_type sp,
414
  ios_base::openmode which
415
  = ios_base::in | ios_base::out) override;
416
  ```