From Jason Turner

[istream.formatted]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcwx742kz/{from.md → to.md} +35 -40
tmp/tmpcwx742kz/{from.md → to.md} RENAMED
@@ -4,11 +4,11 @@
4
 
5
  Each formatted input function begins execution by constructing an object
6
  of class `sentry` with the `noskipws` (second) argument `false`. If the
7
  `sentry` object returns `true`, when converted to a value of type
8
  `bool`, the function endeavors to obtain the requested input. If an
9
- exception is thrown during input then `ios::badbit` is turned on[^19] in
10
  `*this`’s error state. If `(exceptions()&badbit) != 0` then the
11
  exception is rethrown. In any case, the formatted input function
12
  destroys the `sentry` object. If no exception has been thrown, it
13
  returns `*this`.
14
 
@@ -34,32 +34,36 @@ stream data. These extractors behave as formatted input functions (as
34
  described in  [[istream.formatted.reqmts]]). After a sentry object is
35
  constructed, the conversion occurs as if performed by the following code
36
  fragment:
37
 
38
  ``` cpp
39
- typedef num_get< charT,istreambuf_iterator<charT,traits> > numget;
40
  iostate err = iostate::goodbit;
41
  use_facet<numget>(loc).get(*this, 0, *this, err, val);
42
  setstate(err);
43
  ```
44
 
45
  In the above fragment, `loc` stands for the private member of the
46
- `basic_ios` class. The first argument provides an object of the
 
 
47
  `istreambuf_iterator` class which is an iterator pointed to an input
48
- stream. It bypasses istreams and uses streambufs directly. Class
49
- `locale` relies on this type as its interface to `istream`, so that it
50
- does not need to depend directly on `istream`.
 
 
51
 
52
  ``` cpp
53
  operator>>(short& val);
54
  ```
55
 
56
  The conversion occurs as if performed by the following code fragment
57
  (using the same notation as for the preceding code fragment):
58
 
59
  ``` cpp
60
- typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
61
  iostate err = ios_base::goodbit;
62
  long lval;
63
  use_facet<numget>(loc).get(*this, 0, *this, err, lval);
64
  if (lval < numeric_limits<short>::min()) {
65
  err |= ios_base::failbit;
@@ -78,11 +82,11 @@ operator>>(int& val);
78
 
79
  The conversion occurs as if performed by the following code fragment
80
  (using the same notation as for the preceding code fragment):
81
 
82
  ``` cpp
83
- typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
84
  iostate err = ios_base::goodbit;
85
  long lval;
86
  use_facet<numget>(loc).get(*this, 0, *this, err, lval);
87
  if (lval < numeric_limits<int>::min()) {
88
  err |= ios_base::failbit;
@@ -93,54 +97,50 @@ if (lval < numeric_limits<int>::min()) {
93
  } else
94
  val = static_cast<int>(lval);
95
  setstate(err);
96
  ```
97
 
98
- ##### `basic_istream::operator>>` <a id="istream::extractors">[[istream::extractors]]</a>
99
 
100
  ``` cpp
101
- basic_istream<charT,traits>& operator>>
102
- (basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&));
103
  ```
104
 
105
  *Effects:* None. This extractor does not behave as a formatted input
106
- function (as described in  [[istream.formatted.reqmts]].)
107
 
108
- *Returns:* `pf(*this)`.[^20]
109
 
110
  ``` cpp
111
- basic_istream<charT,traits>& operator>>
112
- (basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
113
  ```
114
 
115
  *Effects:* Calls `pf(*this)`. This extractor does not behave as a
116
  formatted input function (as described
117
  in  [[istream.formatted.reqmts]]).
118
 
119
  *Returns:* `*this`.
120
 
121
  ``` cpp
122
- basic_istream<charT,traits>& operator>>
123
- (ios_base& (*pf)(ios_base&));
124
  ```
125
 
126
- *Effects:* Calls `pf(*this)`.[^21] This extractor does not behave as a
127
  formatted input function (as described
128
  in  [[istream.formatted.reqmts]]).
129
 
130
  *Returns:* `*this`.
131
 
132
  ``` cpp
133
  template<class charT, class traits>
134
- basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& in,
135
- charT* s);
136
  template<class traits>
137
- basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
138
- unsigned char* s);
139
  template<class traits>
140
- basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
141
- signed char* s);
142
  ```
143
 
144
  *Effects:* Behaves like a formatted input member (as described
145
  in  [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
146
  constructed, `operator>>` extracts characters and stores them into
@@ -152,12 +152,12 @@ stored.
152
 
153
  Characters are extracted and stored until any of the following occurs:
154
 
155
  - `n-1` characters are stored;
156
  - end of file occurs on the input sequence;
157
- - `ct.is(ct.space,c)` is `true` for the next available input character
158
- `c`, where `ct` is `use_facet<ctype<charT> >(in.getloc())`.
159
 
160
  `operator>>` then stores a null byte (`charT()`) in the next position,
161
  which may be the first position if no characters were extracted.
162
  `operator>>` then calls `width(0)`.
163
 
@@ -166,38 +166,33 @@ which may throw `ios_base::failure` ([[iostate.flags]]).
166
 
167
  *Returns:* `in`.
168
 
169
  ``` cpp
170
  template<class charT, class traits>
171
- basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& in,
172
- charT& c);
173
  template<class traits>
174
- basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
175
- unsigned char& c);
176
  template<class traits>
177
- basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
178
- signed char& c);
179
  ```
180
 
181
  *Effects:* Behaves like a formatted input member (as described
182
  in  [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
183
  constructed a character is extracted from `in`, if one is available, and
184
  stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
185
 
186
  *Returns:* `in`.
187
 
188
  ``` cpp
189
- basic_istream<charT,traits>& operator>>
190
- (basic_streambuf<charT,traits>* sb);
191
  ```
192
 
193
- *Effects:* Behaves as an unformatted input function (as described
194
- in  [[istream.unformatted]], paragraph 1). If `sb` is null, calls
195
- `setstate(failbit)`, which may throw
196
- `ios_base::failure` ([[iostate.flags]]). After a sentry object is
197
- constructed, extracts characters from `*this` and inserts them in the
198
- output sequence controlled by `sb`. Characters are extracted and
199
  inserted until any of the following occurs:
200
 
201
  - end-of-file occurs on the input sequence;
202
  - inserting in the output sequence fails (in which case the character to
203
  be inserted is not extracted);
 
4
 
5
  Each formatted input function begins execution by constructing an object
6
  of class `sentry` with the `noskipws` (second) argument `false`. If the
7
  `sentry` object returns `true`, when converted to a value of type
8
  `bool`, the function endeavors to obtain the requested input. If an
9
+ exception is thrown during input then `ios::badbit` is turned on[^20] in
10
  `*this`’s error state. If `(exceptions()&badbit) != 0` then the
11
  exception is rethrown. In any case, the formatted input function
12
  destroys the `sentry` object. If no exception has been thrown, it
13
  returns `*this`.
14
 
 
34
  described in  [[istream.formatted.reqmts]]). After a sentry object is
35
  constructed, the conversion occurs as if performed by the following code
36
  fragment:
37
 
38
  ``` cpp
39
+ using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
40
  iostate err = iostate::goodbit;
41
  use_facet<numget>(loc).get(*this, 0, *this, err, val);
42
  setstate(err);
43
  ```
44
 
45
  In the above fragment, `loc` stands for the private member of the
46
+ `basic_ios` class.
47
+
48
+ [*Note 1*: The first argument provides an object of the
49
  `istreambuf_iterator` class which is an iterator pointed to an input
50
+ stream. It bypasses istreams and uses streambufs
51
+ directly. *end note*]
52
+
53
+ Class `locale` relies on this type as its interface to `istream`, so
54
+ that it does not need to depend directly on `istream`.
55
 
56
  ``` cpp
57
  operator>>(short& val);
58
  ```
59
 
60
  The conversion occurs as if performed by the following code fragment
61
  (using the same notation as for the preceding code fragment):
62
 
63
  ``` cpp
64
+ using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
65
  iostate err = ios_base::goodbit;
66
  long lval;
67
  use_facet<numget>(loc).get(*this, 0, *this, err, lval);
68
  if (lval < numeric_limits<short>::min()) {
69
  err |= ios_base::failbit;
 
82
 
83
  The conversion occurs as if performed by the following code fragment
84
  (using the same notation as for the preceding code fragment):
85
 
86
  ``` cpp
87
+ using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
88
  iostate err = ios_base::goodbit;
89
  long lval;
90
  use_facet<numget>(loc).get(*this, 0, *this, err, lval);
91
  if (lval < numeric_limits<int>::min()) {
92
  err |= ios_base::failbit;
 
97
  } else
98
  val = static_cast<int>(lval);
99
  setstate(err);
100
  ```
101
 
102
+ ##### `basic_istream::operator>>` <a id="istream.extractors">[[istream.extractors]]</a>
103
 
104
  ``` cpp
105
+ basic_istream<charT, traits>&
106
+ operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
107
  ```
108
 
109
  *Effects:* None. This extractor does not behave as a formatted input
110
+ function (as described in  [[istream.formatted.reqmts]]).
111
 
112
+ *Returns:* `pf(*this)`.[^21]
113
 
114
  ``` cpp
115
+ basic_istream<charT, traits>&
116
+ operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
117
  ```
118
 
119
  *Effects:* Calls `pf(*this)`. This extractor does not behave as a
120
  formatted input function (as described
121
  in  [[istream.formatted.reqmts]]).
122
 
123
  *Returns:* `*this`.
124
 
125
  ``` cpp
126
+ basic_istream<charT, traits>& operator>>(ios_base& (*pf)(ios_base&));
 
127
  ```
128
 
129
+ *Effects:* Calls `pf(*this)`.[^22] This extractor does not behave as a
130
  formatted input function (as described
131
  in  [[istream.formatted.reqmts]]).
132
 
133
  *Returns:* `*this`.
134
 
135
  ``` cpp
136
  template<class charT, class traits>
137
+ basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT* s);
 
138
  template<class traits>
139
+ basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char* s);
 
140
  template<class traits>
141
+ basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char* s);
 
142
  ```
143
 
144
  *Effects:* Behaves like a formatted input member (as described
145
  in  [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
146
  constructed, `operator>>` extracts characters and stores them into
 
152
 
153
  Characters are extracted and stored until any of the following occurs:
154
 
155
  - `n-1` characters are stored;
156
  - end of file occurs on the input sequence;
157
+ - letting `ct` be `use_facet<ctype<charT>>(in.getloc())`,
158
+ `ct.is(ct.space, c)` is `true`.
159
 
160
  `operator>>` then stores a null byte (`charT()`) in the next position,
161
  which may be the first position if no characters were extracted.
162
  `operator>>` then calls `width(0)`.
163
 
 
166
 
167
  *Returns:* `in`.
168
 
169
  ``` cpp
170
  template<class charT, class traits>
171
+ basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
 
172
  template<class traits>
173
+ basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
 
174
  template<class traits>
175
+ basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
 
176
  ```
177
 
178
  *Effects:* Behaves like a formatted input member (as described
179
  in  [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
180
  constructed a character is extracted from `in`, if one is available, and
181
  stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
182
 
183
  *Returns:* `in`.
184
 
185
  ``` cpp
186
+ basic_istream<charT, traits>& operator>>(basic_streambuf<charT, traits>* sb);
 
187
  ```
188
 
189
+ *Effects:* Behaves as an unformatted input function
190
+ ([[istream.unformatted]]). If `sb` is null, calls `setstate(failbit)`,
191
+ which may throw `ios_base::failure` ([[iostate.flags]]). After a sentry
192
+ object is constructed, extracts characters from `*this` and inserts them
193
+ in the output sequence controlled by `sb`. Characters are extracted and
 
194
  inserted until any of the following occurs:
195
 
196
  - end-of-file occurs on the input sequence;
197
  - inserting in the output sequence fails (in which case the character to
198
  be inserted is not extracted);