From Jason Turner

[ofstream]

Diff to HTML by rtfpessoa

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