From Jason Turner

[ostream]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpq_9p480n/{from.md → to.md} +161 -45
tmp/tmpq_9p480n/{from.md → to.md} RENAMED
@@ -4,30 +4,30 @@
4
  namespace std {
5
  template <class charT, class traits = char_traits<charT>>
6
  class basic_ostream : virtual public basic_ios<charT, traits> {
7
  public:
8
  // types (inherited from basic_ios ([ios])):
9
- typedef charT char_type;
10
- typedef typename traits::int_type int_type;
11
- typedef typename traits::pos_type pos_type;
12
- typedef typename traits::off_type off_type;
13
- typedef traits traits_type;
14
 
15
- // [ostream.cons] Constructor/destructor:
16
  explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
17
  virtual ~basic_ostream();
18
 
19
- // [ostream::sentry] Prefix/suffix:
20
  class sentry;
21
 
22
- // [ostream.formatted] Formatted output:
23
- basic_ostream<charT,traits>& operator<<(
24
- basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&));
25
- basic_ostream<charT,traits>& operator<<(
26
- basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
27
- basic_ostream<charT,traits>& operator<<(
28
- ios_base& (*pf)(ios_base&));
29
 
30
  basic_ostream<charT, traits>& operator<<(bool n);
31
  basic_ostream<charT, traits>& operator<<(short n);
32
  basic_ostream<charT, traits>& operator<<(unsigned short n);
33
  basic_ostream<charT, traits>& operator<<(int n);
@@ -39,75 +39,65 @@ namespace std {
39
  basic_ostream<charT, traits>& operator<<(float f);
40
  basic_ostream<charT, traits>& operator<<(double f);
41
  basic_ostream<charT, traits>& operator<<(long double f);
42
 
43
  basic_ostream<charT, traits>& operator<<(const void* p);
44
- basic_ostream<charT,traits>& operator<<(
45
- basic_streambuf<char_type,traits>* sb);
46
 
47
- // [ostream.unformatted] Unformatted output:
48
  basic_ostream<charT, traits>& put(char_type c);
49
  basic_ostream<charT, traits>& write(const char_type* s, streamsize n);
50
 
51
  basic_ostream<charT, traits>& flush();
52
 
53
- // [ostream.seeks] seeks:
54
  pos_type tellp();
55
  basic_ostream<charT, traits>& seekp(pos_type);
56
  basic_ostream<charT, traits>& seekp(off_type, ios_base::seekdir);
 
57
  protected:
 
58
  basic_ostream(const basic_ostream& rhs) = delete;
59
  basic_ostream(basic_ostream&& rhs);
60
 
61
- // [ostream.assign] Assign/swap
62
  basic_ostream& operator=(const basic_ostream& rhs) = delete;
63
  basic_ostream& operator=(basic_ostream&& rhs);
64
  void swap(basic_ostream& rhs);
65
  };
66
 
67
- // [ostream.inserters.character] character inserters
68
  template<class charT, class traits>
69
- basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&,
70
- charT);
71
  template<class charT, class traits>
72
- basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&,
73
- char);
74
  template<class traits>
75
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
76
- char);
77
 
78
- // signed and unsigned
79
  template<class traits>
80
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
81
- signed char);
82
  template<class traits>
83
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
84
- unsigned char);
85
 
86
  template<class charT, class traits>
87
- basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&,
88
- const charT*);
89
  template<class charT, class traits>
90
- basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&,
91
- const char*);
92
  template<class traits>
93
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
94
- const char*);
95
 
96
- // signed and unsigned
97
  template<class traits>
98
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
99
- const signed char*);
100
  template<class traits>
101
- basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&,
102
- const unsigned char*);
103
  }
104
  ```
105
 
106
- The class `basic_ostream` defines a number of member function signatures
107
- that assist in formatting and writing output to output sequences
108
- controlled by a stream buffer.
109
 
110
  Two groups of member function signatures share common properties: the
111
  *formatted output functions* (or *inserters*) and the *unformatted
112
  output functions.* Both groups of output functions generate (or
113
  *insert*) output *characters* by actions equivalent to calling
@@ -119,5 +109,131 @@ If one of these called functions throws an exception, then unless
119
  explicitly noted otherwise the output function sets `badbit` in error
120
  state. If `badbit` is on in `exceptions()`, the output function rethrows
121
  the exception without completing its actions, otherwise it does not
122
  throw anything and treat as an error.
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  namespace std {
5
  template <class charT, class traits = char_traits<charT>>
6
  class basic_ostream : virtual public basic_ios<charT, traits> {
7
  public:
8
  // types (inherited from basic_ios ([ios])):
9
+ using char_type = charT;
10
+ using int_type = typename traits::int_type;
11
+ using pos_type = typename traits::pos_type;
12
+ using off_type = typename traits::off_type;
13
+ using traits_type = traits;
14
 
15
+ // [ostream.cons], constructor/destructor
16
  explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
17
  virtual ~basic_ostream();
18
 
19
+ // [ostream::sentry], prefix/suffix
20
  class sentry;
21
 
22
+ // [ostream.formatted], formatted output
23
+ basic_ostream<charT, traits>&
24
+ operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>&));
25
+ basic_ostream<charT, traits>&
26
+ operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
27
+ basic_ostream<charT, traits>&
28
+ operator<<(ios_base& (*pf)(ios_base&));
29
 
30
  basic_ostream<charT, traits>& operator<<(bool n);
31
  basic_ostream<charT, traits>& operator<<(short n);
32
  basic_ostream<charT, traits>& operator<<(unsigned short n);
33
  basic_ostream<charT, traits>& operator<<(int n);
 
39
  basic_ostream<charT, traits>& operator<<(float f);
40
  basic_ostream<charT, traits>& operator<<(double f);
41
  basic_ostream<charT, traits>& operator<<(long double f);
42
 
43
  basic_ostream<charT, traits>& operator<<(const void* p);
44
+ basic_ostream<charT, traits>& operator<<(nullptr_t);
45
+ basic_ostream<charT, traits>& operator<<(basic_streambuf<char_type, traits>* sb);
46
 
47
+ // [ostream.unformatted], unformatted output
48
  basic_ostream<charT, traits>& put(char_type c);
49
  basic_ostream<charT, traits>& write(const char_type* s, streamsize n);
50
 
51
  basic_ostream<charT, traits>& flush();
52
 
53
+ // [ostream.seeks], seeks
54
  pos_type tellp();
55
  basic_ostream<charT, traits>& seekp(pos_type);
56
  basic_ostream<charT, traits>& seekp(off_type, ios_base::seekdir);
57
+
58
  protected:
59
+ // [ostream.cons], copy/move constructor
60
  basic_ostream(const basic_ostream& rhs) = delete;
61
  basic_ostream(basic_ostream&& rhs);
62
 
63
+ // [ostream.assign], assign and swap
64
  basic_ostream& operator=(const basic_ostream& rhs) = delete;
65
  basic_ostream& operator=(basic_ostream&& rhs);
66
  void swap(basic_ostream& rhs);
67
  };
68
 
69
+ // [ostream.inserters.character], character inserters
70
  template<class charT, class traits>
71
+ basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, charT);
 
72
  template<class charT, class traits>
73
+ basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, char);
 
74
  template<class traits>
75
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char);
 
76
 
 
77
  template<class traits>
78
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char);
 
79
  template<class traits>
80
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char);
 
81
 
82
  template<class charT, class traits>
83
+ basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*);
 
84
  template<class charT, class traits>
85
+ basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*);
 
86
  template<class traits>
87
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char*);
 
88
 
 
89
  template<class traits>
90
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*);
 
91
  template<class traits>
92
+ basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*);
 
93
  }
94
  ```
95
 
96
+ The class template `basic_ostream` defines a number of member function
97
+ signatures that assist in formatting and writing output to output
98
+ sequences controlled by a stream buffer.
99
 
100
  Two groups of member function signatures share common properties: the
101
  *formatted output functions* (or *inserters*) and the *unformatted
102
  output functions.* Both groups of output functions generate (or
103
  *insert*) output *characters* by actions equivalent to calling
 
109
  explicitly noted otherwise the output function sets `badbit` in error
110
  state. If `badbit` is on in `exceptions()`, the output function rethrows
111
  the exception without completing its actions, otherwise it does not
112
  throw anything and treat as an error.
113
 
114
+ ##### `basic_ostream` constructors <a id="ostream.cons">[[ostream.cons]]</a>
115
+
116
+ ``` cpp
117
+ explicit basic_ostream(basic_streambuf<charT, traits>* sb);
118
+ ```
119
+
120
+ *Effects:* Constructs an object of class `basic_ostream`, initializing
121
+ the base class subobject with
122
+ `basic_ios<charT, traits>::init(sb)` ([[basic.ios.cons]]).
123
+
124
+ *Postconditions:* `rdbuf() == sb`.
125
+
126
+ ``` cpp
127
+ basic_ostream(basic_ostream&& rhs);
128
+ ```
129
+
130
+ *Effects:* Move constructs from the rvalue `rhs`. This is accomplished
131
+ by default constructing the base class and calling
132
+ `basic_ios<charT, traits>::move(rhs)` to initialize the base class.
133
+
134
+ ``` cpp
135
+ virtual ~basic_ostream();
136
+ ```
137
+
138
+ *Effects:* Destroys an object of class `basic_ostream`.
139
+
140
+ *Remarks:* Does not perform any operations on `rdbuf()`.
141
+
142
+ ##### Class `basic_ostream` assign and swap <a id="ostream.assign">[[ostream.assign]]</a>
143
+
144
+ ``` cpp
145
+ basic_ostream& operator=(basic_ostream&& rhs);
146
+ ```
147
+
148
+ *Effects:* As if by `swap(rhs)`.
149
+
150
+ *Returns:* `*this`.
151
+
152
+ ``` cpp
153
+ void swap(basic_ostream& rhs);
154
+ ```
155
+
156
+ *Effects:* Calls `basic_ios<charT, traits>::swap(rhs)`.
157
+
158
+ ##### Class `basic_ostream::sentry` <a id="ostream::sentry">[[ostream::sentry]]</a>
159
+
160
+ ``` cpp
161
+ namespace std {
162
+ template <class charT, class traits = char_traits<charT>>
163
+ class basic_ostream<charT, traits>::sentry {
164
+ bool ok_; // exposition only
165
+ public:
166
+ explicit sentry(basic_ostream<charT, traits>& os);
167
+ ~sentry();
168
+ explicit operator bool() const { return ok_; }
169
+
170
+ sentry(const sentry&) = delete;
171
+ sentry& operator=(const sentry&) = delete;
172
+ };
173
+ }
174
+ ```
175
+
176
+ The class `sentry` defines a class that is responsible for doing
177
+ exception safe prefix and suffix operations.
178
+
179
+ ``` cpp
180
+ explicit sentry(basic_ostream<charT, traits>& os);
181
+ ```
182
+
183
+ If `os.good()` is nonzero, prepares for formatted or unformatted output.
184
+ If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^31]
185
+
186
+ If, after any preparation is completed, `os.good()` is `true`,
187
+ `ok_ == true` otherwise, `ok_ == false`. During preparation, the
188
+ constructor may call `setstate(failbit)` (which may throw
189
+ `ios_base::failure` ([[iostate.flags]]))[^32]
190
+
191
+ ``` cpp
192
+ ~sentry();
193
+ ```
194
+
195
+ If
196
+ `(os.flags() & ios_base::unitbuf) && !uncaught_exceptions() && os.good()`
197
+ is `true`, calls `os.rdbuf()->pubsync()`. If that function returns -1,
198
+ sets `badbit` in `os.rdstate()` without propagating an exception.
199
+
200
+ ``` cpp
201
+ explicit operator bool() const;
202
+ ```
203
+
204
+ *Effects:* Returns `ok_`.
205
+
206
+ ##### `basic_ostream` seek members <a id="ostream.seeks">[[ostream.seeks]]</a>
207
+
208
+ Each seek member function begins execution by constructing an object of
209
+ class `sentry`. It returns by destroying the `sentry` object.
210
+
211
+ ``` cpp
212
+ pos_type tellp();
213
+ ```
214
+
215
+ *Returns:* If `fail() != false`, returns `pos_type(-1)` to indicate
216
+ failure. Otherwise, returns `rdbuf()->pubseekoff(0, cur, out)`.
217
+
218
+ ``` cpp
219
+ basic_ostream<charT, traits>& seekp(pos_type pos);
220
+ ```
221
+
222
+ *Effects:* If `fail() != true`, executes
223
+ `rdbuf()->pubseekpos(pos, ios_base::out)`. In case of failure, the
224
+ function calls `setstate(failbit)` (which may throw
225
+ `ios_base::failure`).
226
+
227
+ *Returns:* `*this`.
228
+
229
+ ``` cpp
230
+ basic_ostream<charT, traits>& seekp(off_type off, ios_base::seekdir dir);
231
+ ```
232
+
233
+ *Effects:* If `fail() != true`, executes
234
+ `rdbuf()->pubseekoff(off, dir, ios_base::out)`. In case of failure, the
235
+ function calls `setstate(failbit)` (which may throw
236
+ `ios_base::failure`).
237
+
238
+ *Returns:* `*this`.
239
+