tmp/tmp5mmbg_hc/{from.md → to.md}
RENAMED
|
@@ -3,18 +3,18 @@
|
|
| 3 |
Each unformatted input function begins execution by constructing an
|
| 4 |
object of class `sentry` with the default argument `noskipws` (second)
|
| 5 |
argument `true`. If the `sentry` object returns `true`, when converted
|
| 6 |
to a value of type `bool`, the function endeavors to obtain the
|
| 7 |
requested input. Otherwise, if the sentry constructor exits by throwing
|
| 8 |
-
an exception or if the sentry object returns false, when converted to
|
| 9 |
-
value of type `bool`, the function returns without attempting to
|
| 10 |
-
any input. In either case the number of extracted characters is
|
| 11 |
-
0; unformatted input functions taking a character array of
|
| 12 |
-
as an argument shall also store a null character (using
|
| 13 |
-
the first location of the array. If an exception is thrown
|
| 14 |
-
then `ios::badbit` is turned on[^
|
| 15 |
-
(Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 16 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 17 |
rethrown. It also counts the number of characters extracted. If no
|
| 18 |
exception has been thrown it ends by storing the count in a member
|
| 19 |
object and returning the value specified. In any event the `sentry`
|
| 20 |
object is destroyed before leaving the unformatted input function.
|
|
@@ -22,49 +22,47 @@ object is destroyed before leaving the unformatted input function.
|
|
| 22 |
``` cpp
|
| 23 |
streamsize gcount() const;
|
| 24 |
```
|
| 25 |
|
| 26 |
*Effects:* None. This member function does not behave as an unformatted
|
| 27 |
-
input function (as described
|
| 28 |
|
| 29 |
*Returns:* The number of characters extracted by the last unformatted
|
| 30 |
input member function called for the object.
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
int_type get();
|
| 34 |
```
|
| 35 |
|
| 36 |
*Effects:* Behaves as an unformatted input function (as described
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
`ios_base::failure` ([[iostate.flags]]),
|
| 41 |
|
| 42 |
*Returns:* `c` if available, otherwise `traits::eof()`.
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
basic_istream<charT, traits>& get(char_type& c);
|
| 46 |
```
|
| 47 |
|
| 48 |
*Effects:* Behaves as an unformatted input function (as described
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
`
|
| 52 |
-
|
| 53 |
|
| 54 |
*Returns:* `*this`.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
-
basic_istream<charT,traits>& get(char_type* s, streamsize n,
|
| 58 |
-
char_type delim );
|
| 59 |
```
|
| 60 |
|
| 61 |
*Effects:* Behaves as an unformatted input function (as described
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
|
| 67 |
- `n` is less than one or `n - 1` characters are stored;
|
| 68 |
- end-of-file occurs on the input sequence (in which case the function
|
| 69 |
calls `setstate(eofbit)`);
|
| 70 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
@@ -79,24 +77,22 @@ next successive location of the array.
|
|
| 79 |
|
| 80 |
``` cpp
|
| 81 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 82 |
```
|
| 83 |
|
| 84 |
-
*Effects:* Calls `get(s,n,widen(’\n’))`
|
| 85 |
|
| 86 |
*Returns:* Value returned by the call.
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
-
basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb,
|
| 90 |
-
char_type delim );
|
| 91 |
```
|
| 92 |
|
| 93 |
*Effects:* Behaves as an unformatted input function (as described
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
the following occurs:
|
| 98 |
|
| 99 |
- end-of-file occurs on the input sequence;
|
| 100 |
- inserting in the output sequence fails (in which case the character to
|
| 101 |
be inserted is not extracted);
|
| 102 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
@@ -111,44 +107,45 @@ which may throw `ios_base::failure` ([[iostate.flags]]).
|
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 114 |
```
|
| 115 |
|
| 116 |
-
*Effects:* Calls `get(sb, widen(’\n’))`
|
| 117 |
|
| 118 |
*Returns:* Value returned by the call.
|
| 119 |
|
| 120 |
``` cpp
|
| 121 |
-
basic_istream<charT,traits>& getline(char_type* s, streamsize n,
|
| 122 |
-
char_type delim);
|
| 123 |
```
|
| 124 |
|
| 125 |
*Effects:* Behaves as an unformatted input function (as described
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
|
| 131 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 132 |
calls `setstate(eofbit)`);
|
| 133 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 134 |
(in which case the input character is extracted but not
|
| 135 |
-
stored);[^
|
| 136 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 137 |
the function calls `setstate(failbit)`).
|
| 138 |
|
| 139 |
-
These conditions are tested in the order shown.[^
|
| 140 |
|
| 141 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 142 |
-
(which may throw `ios_base::failure` ([[iostate.flags]])).[^
|
| 143 |
|
| 144 |
In any case, if `n` is greater than zero, it then stores a null
|
| 145 |
character (using `charT()`) into the next successive location of the
|
| 146 |
array.
|
| 147 |
|
| 148 |
*Returns:* `*this`.
|
| 149 |
|
|
|
|
|
|
|
| 150 |
``` cpp
|
| 151 |
#include <iostream>
|
| 152 |
|
| 153 |
int main() {
|
| 154 |
using namespace std;
|
|
@@ -170,27 +167,28 @@ int main() {
|
|
| 170 |
cout << " (" << count << " chars): " << buffer << endl;
|
| 171 |
}
|
| 172 |
}
|
| 173 |
```
|
| 174 |
|
|
|
|
|
|
|
| 175 |
``` cpp
|
| 176 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 177 |
```
|
| 178 |
|
| 179 |
*Returns:* `getline(s, n, widen(’\n’))`
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
-
basic_istream<charT,traits>&
|
| 183 |
-
ignore(streamsize n = 1, int_type delim = traits::eof());
|
| 184 |
```
|
| 185 |
|
| 186 |
*Effects:* Behaves as an unformatted input function (as described
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
|
| 191 |
-
- `n != numeric_limits<streamsize>::max()` ([[limits]]) and `n`
|
| 192 |
characters have been extracted so far
|
| 193 |
- end-of-file occurs on the input sequence (in which case the function
|
| 194 |
calls `setstate(eofbit)`, which may throw
|
| 195 |
`ios_base::failure` ([[iostate.flags]]));
|
| 196 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
|
@@ -204,27 +202,26 @@ until any of the following occurs:
|
|
| 204 |
``` cpp
|
| 205 |
int_type peek();
|
| 206 |
```
|
| 207 |
|
| 208 |
*Effects:* Behaves as an unformatted input function (as described
|
| 209 |
-
|
| 210 |
-
|
| 211 |
|
| 212 |
*Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
|
| 213 |
`rdbuf()->sgetc()`.
|
| 214 |
|
| 215 |
``` cpp
|
| 216 |
basic_istream<charT, traits>& read(char_type* s, streamsize n);
|
| 217 |
```
|
| 218 |
|
| 219 |
*Effects:* Behaves as an unformatted input function (as described
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
following occurs:
|
| 226 |
|
| 227 |
- `n` characters are stored;
|
| 228 |
- end-of-file occurs on the input sequence (in which case the function
|
| 229 |
calls `setstate(failbit | eofbit)`, which may throw
|
| 230 |
`ios_base::failure` ([[iostate.flags]])).
|
|
@@ -234,17 +231,16 @@ following occurs:
|
|
| 234 |
``` cpp
|
| 235 |
streamsize readsome(char_type* s, streamsize n);
|
| 236 |
```
|
| 237 |
|
| 238 |
*Effects:* Behaves as an unformatted input function (as described
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
characters;
|
| 246 |
|
| 247 |
- If `rdbuf()->in_avail() == 0`, extracts no characters
|
| 248 |
- If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
|
| 249 |
|
| 250 |
*Returns:* The number of characters extracted.
|
|
@@ -252,86 +248,87 @@ characters;
|
|
| 252 |
``` cpp
|
| 253 |
basic_istream<charT, traits>& putback(char_type c);
|
| 254 |
```
|
| 255 |
|
| 256 |
*Effects:* Behaves as an unformatted input function (as described
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
|
|
|
| 265 |
|
| 266 |
*Returns:* `*this`.
|
| 267 |
|
| 268 |
``` cpp
|
| 269 |
basic_istream<charT, traits>& unget();
|
| 270 |
```
|
| 271 |
|
| 272 |
*Effects:* Behaves as an unformatted input function (as described
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
| 281 |
|
| 282 |
*Returns:* `*this`.
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
int sync();
|
| 286 |
```
|
| 287 |
|
| 288 |
*Effects:* Behaves as an unformatted input function (as described
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
`setstate(badbit)` (which may throw
|
| 295 |
`ios_base::failure` ([[iostate.flags]]), and returns `-1`. Otherwise,
|
| 296 |
returns zero.
|
| 297 |
|
| 298 |
``` cpp
|
| 299 |
pos_type tellg();
|
| 300 |
```
|
| 301 |
|
| 302 |
*Effects:* Behaves as an unformatted input function (as described
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
|
| 307 |
*Returns:* After constructing a sentry object, if `fail() != false`,
|
| 308 |
returns `pos_type(-1)` to indicate failure. Otherwise, returns
|
| 309 |
`rdbuf()->pubseekoff(0, cur, in)`.
|
| 310 |
|
| 311 |
``` cpp
|
| 312 |
basic_istream<charT, traits>& seekg(pos_type pos);
|
| 313 |
```
|
| 314 |
|
| 315 |
*Effects:* Behaves as an unformatted input function (as described
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
`ios_base::failure`).
|
| 323 |
|
| 324 |
*Returns:* `*this`.
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
|
| 328 |
```
|
| 329 |
|
| 330 |
*Effects:* Behaves as an unformatted input function (as described
|
| 331 |
-
|
| 332 |
-
the number of characters extracted and does not affect the value
|
| 333 |
returned by subsequent calls to `gcount()`. After constructing a sentry
|
| 334 |
object, if `fail() != true`, executes
|
| 335 |
`rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
|
| 336 |
function calls `setstate(failbit)` (which may throw
|
| 337 |
`ios_base::failure`).
|
|
|
|
| 3 |
Each unformatted input function begins execution by constructing an
|
| 4 |
object of class `sentry` with the default argument `noskipws` (second)
|
| 5 |
argument `true`. If the `sentry` object returns `true`, when converted
|
| 6 |
to a value of type `bool`, the function endeavors to obtain the
|
| 7 |
requested input. Otherwise, if the sentry constructor exits by throwing
|
| 8 |
+
an exception or if the sentry object returns `false`, when converted to
|
| 9 |
+
a value of type `bool`, the function returns without attempting to
|
| 10 |
+
obtain any input. In either case the number of extracted characters is
|
| 11 |
+
set to 0; unformatted input functions taking a character array of
|
| 12 |
+
nonzero size as an argument shall also store a null character (using
|
| 13 |
+
`charT()`) in the first location of the array. If an exception is thrown
|
| 14 |
+
during input then `ios::badbit` is turned on[^23] in `*this`’s error
|
| 15 |
+
state. (Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 16 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 17 |
rethrown. It also counts the number of characters extracted. If no
|
| 18 |
exception has been thrown it ends by storing the count in a member
|
| 19 |
object and returning the value specified. In any event the `sentry`
|
| 20 |
object is destroyed before leaving the unformatted input function.
|
|
|
|
| 22 |
``` cpp
|
| 23 |
streamsize gcount() const;
|
| 24 |
```
|
| 25 |
|
| 26 |
*Effects:* None. This member function does not behave as an unformatted
|
| 27 |
+
input function (as described above).
|
| 28 |
|
| 29 |
*Returns:* The number of characters extracted by the last unformatted
|
| 30 |
input member function called for the object.
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
int_type get();
|
| 34 |
```
|
| 35 |
|
| 36 |
*Effects:* Behaves as an unformatted input function (as described
|
| 37 |
+
above). After constructing a sentry object, extracts a character `c`, if
|
| 38 |
+
one is available. Otherwise, the function calls `setstate(failbit)`,
|
| 39 |
+
which may throw `ios_base::failure` ([[iostate.flags]]),
|
|
|
|
| 40 |
|
| 41 |
*Returns:* `c` if available, otherwise `traits::eof()`.
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
basic_istream<charT, traits>& get(char_type& c);
|
| 45 |
```
|
| 46 |
|
| 47 |
*Effects:* Behaves as an unformatted input function (as described
|
| 48 |
+
above). After constructing a sentry object, extracts a character, if one
|
| 49 |
+
is available, and assigns it to `c`.[^24] Otherwise, the function calls
|
| 50 |
+
`setstate(failbit)` (which may throw
|
| 51 |
+
`ios_base::failure` ([[iostate.flags]])).
|
| 52 |
|
| 53 |
*Returns:* `*this`.
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
+
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
*Effects:* Behaves as an unformatted input function (as described
|
| 60 |
+
above). After constructing a sentry object, extracts characters and
|
| 61 |
+
stores them into successive locations of an array whose first element is
|
| 62 |
+
designated by `s`.[^25] Characters are extracted and stored until any of
|
| 63 |
+
the following occurs:
|
| 64 |
|
| 65 |
- `n` is less than one or `n - 1` characters are stored;
|
| 66 |
- end-of-file occurs on the input sequence (in which case the function
|
| 67 |
calls `setstate(eofbit)`);
|
| 68 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
|
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 80 |
```
|
| 81 |
|
| 82 |
+
*Effects:* Calls `get(s, n, widen(’\n’))`.
|
| 83 |
|
| 84 |
*Returns:* Value returned by the call.
|
| 85 |
|
| 86 |
``` cpp
|
| 87 |
+
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb, char_type delim);
|
|
|
|
| 88 |
```
|
| 89 |
|
| 90 |
*Effects:* Behaves as an unformatted input function (as described
|
| 91 |
+
above). After constructing a sentry object, extracts characters and
|
| 92 |
+
inserts them in the output sequence controlled by `sb`. Characters are
|
| 93 |
+
extracted and inserted until any of the following occurs:
|
|
|
|
| 94 |
|
| 95 |
- end-of-file occurs on the input sequence;
|
| 96 |
- inserting in the output sequence fails (in which case the character to
|
| 97 |
be inserted is not extracted);
|
| 98 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
|
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 110 |
```
|
| 111 |
|
| 112 |
+
*Effects:* Calls `get(sb, widen(’\n’))`.
|
| 113 |
|
| 114 |
*Returns:* Value returned by the call.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
+
basic_istream<charT, traits>& getline(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 118 |
```
|
| 119 |
|
| 120 |
*Effects:* Behaves as an unformatted input function (as described
|
| 121 |
+
above). After constructing a sentry object, extracts characters and
|
| 122 |
+
stores them into successive locations of an array whose first element is
|
| 123 |
+
designated by `s`.[^26] Characters are extracted and stored until one of
|
| 124 |
+
the following occurs:
|
| 125 |
|
| 126 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 127 |
calls `setstate(eofbit)`);
|
| 128 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 129 |
(in which case the input character is extracted but not
|
| 130 |
+
stored);[^27]
|
| 131 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 132 |
the function calls `setstate(failbit)`).
|
| 133 |
|
| 134 |
+
These conditions are tested in the order shown.[^28]
|
| 135 |
|
| 136 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 137 |
+
(which may throw `ios_base::failure` ([[iostate.flags]])).[^29]
|
| 138 |
|
| 139 |
In any case, if `n` is greater than zero, it then stores a null
|
| 140 |
character (using `charT()`) into the next successive location of the
|
| 141 |
array.
|
| 142 |
|
| 143 |
*Returns:* `*this`.
|
| 144 |
|
| 145 |
+
[*Example 1*:
|
| 146 |
+
|
| 147 |
``` cpp
|
| 148 |
#include <iostream>
|
| 149 |
|
| 150 |
int main() {
|
| 151 |
using namespace std;
|
|
|
|
| 167 |
cout << " (" << count << " chars): " << buffer << endl;
|
| 168 |
}
|
| 169 |
}
|
| 170 |
```
|
| 171 |
|
| 172 |
+
— *end example*]
|
| 173 |
+
|
| 174 |
``` cpp
|
| 175 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 176 |
```
|
| 177 |
|
| 178 |
*Returns:* `getline(s, n, widen(’\n’))`
|
| 179 |
|
| 180 |
``` cpp
|
| 181 |
+
basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::eof());
|
|
|
|
| 182 |
```
|
| 183 |
|
| 184 |
*Effects:* Behaves as an unformatted input function (as described
|
| 185 |
+
above). After constructing a sentry object, extracts characters and
|
| 186 |
+
discards them. Characters are extracted until any of the following
|
| 187 |
+
occurs:
|
| 188 |
|
| 189 |
+
- `n != numeric_limits<streamsize>::max()` ([[numeric.limits]]) and `n`
|
| 190 |
characters have been extracted so far
|
| 191 |
- end-of-file occurs on the input sequence (in which case the function
|
| 192 |
calls `setstate(eofbit)`, which may throw
|
| 193 |
`ios_base::failure` ([[iostate.flags]]));
|
| 194 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
|
|
|
| 202 |
``` cpp
|
| 203 |
int_type peek();
|
| 204 |
```
|
| 205 |
|
| 206 |
*Effects:* Behaves as an unformatted input function (as described
|
| 207 |
+
above). After constructing a sentry object, reads but does not extract
|
| 208 |
+
the current input character.
|
| 209 |
|
| 210 |
*Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
|
| 211 |
`rdbuf()->sgetc()`.
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
basic_istream<charT, traits>& read(char_type* s, streamsize n);
|
| 215 |
```
|
| 216 |
|
| 217 |
*Effects:* Behaves as an unformatted input function (as described
|
| 218 |
+
above). After constructing a sentry object, if `!good()` calls
|
| 219 |
+
`setstate(failbit)` which may throw an exception, and return. Otherwise
|
| 220 |
+
extracts characters and stores them into successive locations of an
|
| 221 |
+
array whose first element is designated by `s`.[^30] Characters are
|
| 222 |
+
extracted and stored until either of the following occurs:
|
|
|
|
| 223 |
|
| 224 |
- `n` characters are stored;
|
| 225 |
- end-of-file occurs on the input sequence (in which case the function
|
| 226 |
calls `setstate(failbit | eofbit)`, which may throw
|
| 227 |
`ios_base::failure` ([[iostate.flags]])).
|
|
|
|
| 231 |
``` cpp
|
| 232 |
streamsize readsome(char_type* s, streamsize n);
|
| 233 |
```
|
| 234 |
|
| 235 |
*Effects:* Behaves as an unformatted input function (as described
|
| 236 |
+
above). After constructing a sentry object, if `!good()` calls
|
| 237 |
+
`setstate(failbit)` which may throw an exception, and return. Otherwise
|
| 238 |
+
extracts characters and stores them into successive locations of an
|
| 239 |
+
array whose first element is designated by `s`. If
|
| 240 |
+
`rdbuf()->in_avail() == -1`, calls `setstate(eofbit)` (which may throw
|
| 241 |
+
`ios_base::failure` ([[iostate.flags]])), and extracts no characters;
|
|
|
|
| 242 |
|
| 243 |
- If `rdbuf()->in_avail() == 0`, extracts no characters
|
| 244 |
- If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
|
| 245 |
|
| 246 |
*Returns:* The number of characters extracted.
|
|
|
|
| 248 |
``` cpp
|
| 249 |
basic_istream<charT, traits>& putback(char_type c);
|
| 250 |
```
|
| 251 |
|
| 252 |
*Effects:* Behaves as an unformatted input function (as described
|
| 253 |
+
above), except that the function first clears `eofbit`. After
|
| 254 |
+
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 255 |
+
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 256 |
+
calls `rdbuf->sputbackc()`. If `rdbuf()` is null, or if `sputbackc()`
|
| 257 |
+
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 258 |
+
`ios_base::failure` ([[iostate.flags]])).
|
| 259 |
+
|
| 260 |
+
[*Note 1*: This function extracts no characters, so the value returned
|
| 261 |
+
by the next call to `gcount()` is 0. — *end note*]
|
| 262 |
|
| 263 |
*Returns:* `*this`.
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
basic_istream<charT, traits>& unget();
|
| 267 |
```
|
| 268 |
|
| 269 |
*Effects:* Behaves as an unformatted input function (as described
|
| 270 |
+
above), except that the function first clears `eofbit`. After
|
| 271 |
+
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 272 |
+
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 273 |
+
calls `rdbuf()->sungetc()`. If `rdbuf()` is null, or if `sungetc()`
|
| 274 |
+
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 275 |
+
`ios_base::failure` ([[iostate.flags]])).
|
| 276 |
+
|
| 277 |
+
[*Note 2*: This function extracts no characters, so the value returned
|
| 278 |
+
by the next call to `gcount()` is 0. — *end note*]
|
| 279 |
|
| 280 |
*Returns:* `*this`.
|
| 281 |
|
| 282 |
``` cpp
|
| 283 |
int sync();
|
| 284 |
```
|
| 285 |
|
| 286 |
*Effects:* Behaves as an unformatted input function (as described
|
| 287 |
+
above), except that it does not count the number of characters extracted
|
| 288 |
+
and does not affect the value returned by subsequent calls to
|
| 289 |
+
`gcount()`. After constructing a sentry object, if `rdbuf()` is a null
|
| 290 |
+
pointer, returns `-1`. Otherwise, calls `rdbuf()->pubsync()` and, if
|
| 291 |
+
that function returns `-1` calls `setstate(badbit)` (which may throw
|
|
|
|
| 292 |
`ios_base::failure` ([[iostate.flags]]), and returns `-1`. Otherwise,
|
| 293 |
returns zero.
|
| 294 |
|
| 295 |
``` cpp
|
| 296 |
pos_type tellg();
|
| 297 |
```
|
| 298 |
|
| 299 |
*Effects:* Behaves as an unformatted input function (as described
|
| 300 |
+
above), except that it does not count the number of characters extracted
|
| 301 |
+
and does not affect the value returned by subsequent calls to
|
| 302 |
+
`gcount()`.
|
| 303 |
|
| 304 |
*Returns:* After constructing a sentry object, if `fail() != false`,
|
| 305 |
returns `pos_type(-1)` to indicate failure. Otherwise, returns
|
| 306 |
`rdbuf()->pubseekoff(0, cur, in)`.
|
| 307 |
|
| 308 |
``` cpp
|
| 309 |
basic_istream<charT, traits>& seekg(pos_type pos);
|
| 310 |
```
|
| 311 |
|
| 312 |
*Effects:* Behaves as an unformatted input function (as described
|
| 313 |
+
above), except that the function first clears `eofbit`, it does not
|
| 314 |
+
count the number of characters extracted, and it does not affect the
|
| 315 |
+
value returned by subsequent calls to `gcount()`. After constructing a
|
| 316 |
+
sentry object, if `fail() != true`, executes
|
| 317 |
+
`rdbuf()->pubseekpos(pos, ios_base::in)`. In case of failure, the
|
| 318 |
+
function calls `setstate(failbit)` (which may throw
|
| 319 |
`ios_base::failure`).
|
| 320 |
|
| 321 |
*Returns:* `*this`.
|
| 322 |
|
| 323 |
``` cpp
|
| 324 |
basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
|
| 325 |
```
|
| 326 |
|
| 327 |
*Effects:* Behaves as an unformatted input function (as described
|
| 328 |
+
above), except that the function first clears `eofbit`, does not count
|
| 329 |
+
the number of characters extracted, and does not affect the value
|
| 330 |
returned by subsequent calls to `gcount()`. After constructing a sentry
|
| 331 |
object, if `fail() != true`, executes
|
| 332 |
`rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
|
| 333 |
function calls `setstate(failbit)` (which may throw
|
| 334 |
`ios_base::failure`).
|