From Jason Turner

[filebuf.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpi59ov9f1/{from.md → to.md} +85 -0
tmp/tmpi59ov9f1/{from.md → to.md} RENAMED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="filebuf.general">[[filebuf.general]]</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:
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
+ // [filebuf.cons], constructors/destructor
15
+ basic_filebuf();
16
+ basic_filebuf(const basic_filebuf&) = delete;
17
+ basic_filebuf(basic_filebuf&& rhs);
18
+ virtual ~basic_filebuf();
19
+
20
+ // [filebuf.assign], assignment 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
26
+ bool is_open() const;
27
+ basic_filebuf* open(const char* s, ios_base::openmode mode);
28
+ basic_filebuf* open(const filesystem::path::value_type* s,
29
+ ios_base::openmode mode); // wide systems only; see [fstream.syn]
30
+ basic_filebuf* open(const string& s,
31
+ ios_base::openmode mode);
32
+ basic_filebuf* open(const filesystem::path& s,
33
+ ios_base::openmode mode);
34
+ basic_filebuf* close();
35
+
36
+ protected:
37
+ // [filebuf.virtuals], overridden virtual functions
38
+ streamsize showmanyc() override;
39
+ int_type underflow() override;
40
+ int_type uflow() override;
41
+ int_type pbackfail(int_type c = traits::eof()) override;
42
+ int_type overflow (int_type c = traits::eof()) override;
43
+
44
+ basic_streambuf<charT, traits>* setbuf(char_type* s,
45
+ streamsize n) override;
46
+ pos_type seekoff(off_type off, ios_base::seekdir way,
47
+ ios_base::openmode which
48
+ = ios_base::in | ios_base::out) override;
49
+ pos_type seekpos(pos_type sp,
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
+ ```
57
+
58
+ The class `basic_filebuf<charT, traits>` associates both the input
59
+ sequence and the output sequence with a file.
60
+
61
+ The restrictions on reading and writing a sequence controlled by an
62
+ object of class `basic_filebuf<charT, traits>` are the same as for
63
+ reading and writing with the C standard library `FILE`s.
64
+
65
+ In particular:
66
+
67
+ - If the file is not open for reading the input sequence cannot be read.
68
+ - If the file is not open for writing the output sequence cannot be
69
+ written.
70
+ - A joint file position is maintained for both the input sequence and
71
+ the output sequence.
72
+
73
+ An instance of `basic_filebuf` behaves as described in  [[filebuf]]
74
+ provided `traits::pos_type` is `fpos<traits::{}state_type>`. Otherwise
75
+ the behavior is undefined.
76
+
77
+ In order to support file I/O and multibyte/wide character conversion,
78
+ conversions are performed using members of a facet, referred to as
79
+ `a_codecvt` in following subclauses, obtained as if by
80
+
81
+ ``` cpp
82
+ const codecvt<charT, char, typename traits::state_type>& a_codecvt =
83
+ use_facet<codecvt<charT, char, typename traits::state_type>>(getloc());
84
+ ```
85
+