- tmp/tmpm4ldjf09/{from.md → to.md} +250 -119
tmp/tmpm4ldjf09/{from.md → to.md}
RENAMED
|
@@ -55,15 +55,15 @@ The classes of Clause [[input.output]] with template arguments `charT`
|
|
| 55 |
and `traits` behave as described if `traits::pos_type` and
|
| 56 |
`traits::off_type` are `streampos` and `streamoff` respectively. Except
|
| 57 |
as noted explicitly below, their behavior when `traits::pos_type` and
|
| 58 |
`traits::off_type` are other types is *implementation-defined*.
|
| 59 |
|
| 60 |
-
In the classes of Clause [[input.output]], a template
|
| 61 |
-
|
| 62 |
-
`
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
### Thread safety <a id="iostreams.threadsafety">[[iostreams.threadsafety]]</a>
|
| 67 |
|
| 68 |
Concurrent access to a stream object ([[string.streams]],
|
| 69 |
[[file.streams]]), stream buffer object ([[stream.buffers]]), or C
|
|
@@ -400,13 +400,13 @@ namespace std {
|
|
| 400 |
enum class io_errc {
|
| 401 |
stream = 1
|
| 402 |
};
|
| 403 |
|
| 404 |
template <> struct is_error_code_enum<io_errc> : public true_type { };
|
| 405 |
-
error_code make_error_code(io_errc e);
|
| 406 |
-
error_condition make_error_condition(io_errc e);
|
| 407 |
-
const error_category& iostream_category();
|
| 408 |
}
|
| 409 |
```
|
| 410 |
|
| 411 |
### Types <a id="stream.types">[[stream.types]]</a>
|
| 412 |
|
|
@@ -471,13 +471,13 @@ namespace std {
|
|
| 471 |
static constexpr openmode out = unspecified;
|
| 472 |
static constexpr openmode trunc = unspecified;
|
| 473 |
|
| 474 |
// [ios::seekdir] seekdir
|
| 475 |
typedef T4 seekdir;
|
| 476 |
-
static constexpr
|
| 477 |
-
static constexpr
|
| 478 |
-
static constexpr
|
| 479 |
|
| 480 |
class Init;
|
| 481 |
|
| 482 |
// [fmtflags.state] fmtflags state:
|
| 483 |
fmtflags flags() const;
|
|
@@ -515,13 +515,13 @@ namespace std {
|
|
| 515 |
|
| 516 |
protected:
|
| 517 |
ios_base();
|
| 518 |
|
| 519 |
private:
|
| 520 |
-
static int index; // exposition
|
| 521 |
-
long* iarray; // exposition
|
| 522 |
-
void** parray; // exposition
|
| 523 |
};
|
| 524 |
}
|
| 525 |
```
|
| 526 |
|
| 527 |
`ios_base`
|
|
@@ -577,11 +577,11 @@ number reported by the operating system. Errors arising from within the
|
|
| 577 |
stream library would typically be reported as
|
| 578 |
`error_code(io_errc::stream,
|
| 579 |
iostream_category())`.
|
| 580 |
|
| 581 |
``` cpp
|
| 582 |
-
explicit failure(const string& msg,
|
| 583 |
```
|
| 584 |
|
| 585 |
*Effects:* Constructs an object of class `failure` by constructing the
|
| 586 |
base class with `msg` and `ec`.
|
| 587 |
|
|
@@ -704,11 +704,11 @@ namespace std {
|
|
| 704 |
class ios_base::Init {
|
| 705 |
public:
|
| 706 |
Init();
|
| 707 |
~Init();
|
| 708 |
private:
|
| 709 |
-
static int init_cnt; // exposition
|
| 710 |
};
|
| 711 |
}
|
| 712 |
```
|
| 713 |
|
| 714 |
The class `Init` describes an object whose construction ensures the
|
|
@@ -869,11 +869,11 @@ c = fgetc(f);
|
|
| 869 |
```
|
| 870 |
|
| 871 |
is the same as the effect of
|
| 872 |
|
| 873 |
``` cpp
|
| 874 |
-
c = str.rdbuf()->sbumpc(
|
| 875 |
```
|
| 876 |
|
| 877 |
for any sequences of characters; and the effect of pushing back a
|
| 878 |
character `c` by
|
| 879 |
|
|
@@ -895,10 +895,13 @@ for any sequence of characters.[^6]
|
|
| 895 |
static int xalloc();
|
| 896 |
```
|
| 897 |
|
| 898 |
*Returns:* `index` `++`.
|
| 899 |
|
|
|
|
|
|
|
|
|
|
| 900 |
``` cpp
|
| 901 |
long& iword(int idx);
|
| 902 |
```
|
| 903 |
|
| 904 |
*Effects:* If `iarray` is a null pointer, allocates an array of `long`
|
|
@@ -968,11 +971,11 @@ ios_base();
|
|
| 968 |
construction. The object’s members shall be initialized by calling
|
| 969 |
`basic_ios::init` before the object’s first use or before it is
|
| 970 |
destroyed, whichever comes first; otherwise the behavior is undefined.
|
| 971 |
|
| 972 |
``` cpp
|
| 973 |
-
~ios_base()
|
| 974 |
```
|
| 975 |
|
| 976 |
*Effects:* Destroys an object of class `ios_base`. Calls each registered
|
| 977 |
callback pair `(fn, index)` ([[ios.base.callback]]) as
|
| 978 |
`(*fn)(erase_event, *this, index)` at such time that any `ios_base`
|
|
@@ -986,11 +989,11 @@ namespace std {
|
|
| 986 |
public:
|
| 987 |
// [fpos.members] Members
|
| 988 |
stateT state() const;
|
| 989 |
void state(stateT);
|
| 990 |
private;
|
| 991 |
-
stateT st; // exposition
|
| 992 |
};
|
| 993 |
}
|
| 994 |
```
|
| 995 |
|
| 996 |
#### `fpos` members <a id="fpos.members">[[fpos.members]]</a>
|
|
@@ -1586,23 +1589,23 @@ ios_base& defaultfloat(ios_base& str);
|
|
| 1586 |
*Returns:* `str`.
|
| 1587 |
|
| 1588 |
#### Error reporting <a id="error.reporting">[[error.reporting]]</a>
|
| 1589 |
|
| 1590 |
``` cpp
|
| 1591 |
-
error_code make_error_code(io_errc e);
|
| 1592 |
```
|
| 1593 |
|
| 1594 |
*Returns:* `error_code(static_cast<int>(e), iostream_category())`.
|
| 1595 |
|
| 1596 |
``` cpp
|
| 1597 |
-
error_condition make_error_condition(io_errc e);
|
| 1598 |
```
|
| 1599 |
|
| 1600 |
*Returns:* `error_condition(static_cast<int>(e), iostream_category())`.
|
| 1601 |
|
| 1602 |
``` cpp
|
| 1603 |
-
const error_category& iostream_category();
|
| 1604 |
```
|
| 1605 |
|
| 1606 |
*Returns:* A reference to an object of a type derived from class
|
| 1607 |
`error_category`.
|
| 1608 |
|
|
@@ -2047,11 +2050,11 @@ void setp(char_type* pbeg, char_type* pend);
|
|
| 2047 |
#### `basic_streambuf` virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
|
| 2048 |
|
| 2049 |
##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
|
| 2050 |
|
| 2051 |
``` cpp
|
| 2052 |
-
void imbue(const locale&)
|
| 2053 |
```
|
| 2054 |
|
| 2055 |
*Effects:* Change any translations based on locale.
|
| 2056 |
|
| 2057 |
*Remarks:* Allows the derived class to be informed of changes in locale
|
|
@@ -2203,11 +2206,11 @@ The *pending sequence* is defined as for `underflow()`, with the
|
|
| 2203 |
modifications that
|
| 2204 |
|
| 2205 |
- If `traits::eq_int_type(c,traits::eof())` returns `true`, then the
|
| 2206 |
input sequence is backed up one character before the pending sequence
|
| 2207 |
is determined.
|
| 2208 |
-
- If `traits::eq_int_type(c,traits::eof())`
|
| 2209 |
prepended. Whether the input sequence is backed up or modified in any
|
| 2210 |
other way is unspecified.
|
| 2211 |
|
| 2212 |
On return, the constraints of `gptr()`, `eback()`, and `pptr()` are the
|
| 2213 |
same as for `underflow()`.
|
|
@@ -2225,14 +2228,42 @@ Returns some value other than `traits::eof()` to indicate success.
|
|
| 2225 |
|
| 2226 |
``` cpp
|
| 2227 |
streamsize xsputn(const char_type* s, streamsize n);
|
| 2228 |
```
|
| 2229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2230 |
``` cpp
|
| 2231 |
int_type overflow(int_type c = traits::eof());
|
| 2232 |
```
|
| 2233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2234 |
## Formatting and manipulators <a id="iostream.format">[[iostream.format]]</a>
|
| 2235 |
|
| 2236 |
### Overview <a id="iostream.format.overview">[[iostream.format.overview]]</a>
|
| 2237 |
|
| 2238 |
\synopsis{Header \texttt{\<istream\>} synopsis}
|
|
@@ -2289,10 +2320,21 @@ namespace std {
|
|
| 2289 |
T6 setw(int n);
|
| 2290 |
template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
|
| 2291 |
template <class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
|
| 2292 |
template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
|
| 2293 |
template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2294 |
}
|
| 2295 |
```
|
| 2296 |
|
| 2297 |
### Input streams <a id="input.streams">[[input.streams]]</a>
|
| 2298 |
|
|
@@ -2481,11 +2523,11 @@ values returned by `gcount()` and `rhs.gcount()`.
|
|
| 2481 |
``` cpp
|
| 2482 |
namespace std {
|
| 2483 |
template <class charT,class traits = char_traits<charT> >
|
| 2484 |
class basic_istream<charT,traits>::sentry {
|
| 2485 |
typedef traits traits_type;
|
| 2486 |
-
bool ok_; // exposition
|
| 2487 |
public:
|
| 2488 |
explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
|
| 2489 |
~sentry();
|
| 2490 |
explicit operator bool() const { return ok_; }
|
| 2491 |
sentry(const sentry&) = delete;
|
|
@@ -2499,19 +2541,19 @@ exception safe prefix and suffix operations.
|
|
| 2499 |
|
| 2500 |
``` cpp
|
| 2501 |
explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
|
| 2502 |
```
|
| 2503 |
|
| 2504 |
-
*Effects:* If `is.good()` is `false`, calls is.setstate(failbit).
|
| 2505 |
Otherwise, prepares for formatted or unformatted input. First, if
|
| 2506 |
`is.tie()` is not a null pointer, the function calls `is.tie()->flush()`
|
| 2507 |
to synchronize the output sequence with any associated external C
|
| 2508 |
stream. Except that this call can be suppressed if the put area of
|
| 2509 |
`is.tie()` is empty. Further an implementation is allowed to defer the
|
| 2510 |
call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
|
| 2511 |
such call occurs before the `sentry` object is destroyed, the call to
|
| 2512 |
-
`flush` may be eliminated entirely.[^
|
| 2513 |
`is.flags() & ios_base::skipws` is nonzero, the function extracts and
|
| 2514 |
discards each character as long as the next available input character
|
| 2515 |
`c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
|
| 2516 |
`is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
|
| 2517 |
`setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
|
|
@@ -2531,11 +2573,11 @@ if (ctype.is(ctype.space,c)!=0)
|
|
| 2531 |
```
|
| 2532 |
|
| 2533 |
If, after any preparation is completed, `is.good()` is `true`,
|
| 2534 |
`ok_ != false` otherwise, `ok_ == false`. During preparation, the
|
| 2535 |
constructor may call `setstate(failbit)` (which may throw
|
| 2536 |
-
`ios_base::failure` ([[iostate.flags]]))[^
|
| 2537 |
|
| 2538 |
``` cpp
|
| 2539 |
~sentry();
|
| 2540 |
```
|
| 2541 |
|
|
@@ -2553,11 +2595,11 @@ explicit operator bool() const;
|
|
| 2553 |
|
| 2554 |
Each formatted input function begins execution by constructing an object
|
| 2555 |
of class `sentry` with the `noskipws` (second) argument `false`. If the
|
| 2556 |
`sentry` object returns `true`, when converted to a value of type
|
| 2557 |
`bool`, the function endeavors to obtain the requested input. If an
|
| 2558 |
-
exception is thrown during input then `ios::badbit` is turned on[^
|
| 2559 |
`*this`’s error state. If `(exceptions()&badbit) != 0` then the
|
| 2560 |
exception is rethrown. In any case, the formatted input function
|
| 2561 |
destroys the `sentry` object. If no exception has been thrown, it
|
| 2562 |
returns `*this`.
|
| 2563 |
|
|
@@ -2646,17 +2688,17 @@ setstate(err);
|
|
| 2646 |
|
| 2647 |
##### `basic_istream::operator>>` <a id="istream::extractors">[[istream::extractors]]</a>
|
| 2648 |
|
| 2649 |
``` cpp
|
| 2650 |
basic_istream<charT,traits>& operator>>
|
| 2651 |
-
(basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&))
|
| 2652 |
```
|
| 2653 |
|
| 2654 |
*Effects:* None. This extractor does not behave as a formatted input
|
| 2655 |
function (as described in [[istream.formatted.reqmts]].)
|
| 2656 |
|
| 2657 |
-
*Returns:* `pf(*this)`.[^
|
| 2658 |
|
| 2659 |
``` cpp
|
| 2660 |
basic_istream<charT,traits>& operator>>
|
| 2661 |
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
|
| 2662 |
```
|
|
@@ -2670,11 +2712,11 @@ in [[istream.formatted.reqmts]]).
|
|
| 2670 |
``` cpp
|
| 2671 |
basic_istream<charT,traits>& operator>>
|
| 2672 |
(ios_base& (*pf)(ios_base&));
|
| 2673 |
```
|
| 2674 |
|
| 2675 |
-
*Effects:* Calls `pf(*this)`.[^
|
| 2676 |
formatted input function (as described
|
| 2677 |
in [[istream.formatted.reqmts]]).
|
| 2678 |
|
| 2679 |
*Returns:* `*this`.
|
| 2680 |
|
|
@@ -2772,11 +2814,11 @@ an exception or if the sentry object returns false, when converted to a
|
|
| 2772 |
value of type `bool`, the function returns without attempting to obtain
|
| 2773 |
any input. In either case the number of extracted characters is set to
|
| 2774 |
0; unformatted input functions taking a character array of non-zero size
|
| 2775 |
as an argument shall also store a null character (using `charT()`) in
|
| 2776 |
the first location of the array. If an exception is thrown during input
|
| 2777 |
-
then `ios::badbit` is turned on[^
|
| 2778 |
(Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 2779 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 2780 |
rethrown. It also counts the number of characters extracted. If no
|
| 2781 |
exception has been thrown it ends by storing the count in a member
|
| 2782 |
object and returning the value specified. In any event the `sentry`
|
|
@@ -2809,11 +2851,11 @@ basic_istream<charT,traits>& get(char_type& c);
|
|
| 2809 |
```
|
| 2810 |
|
| 2811 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2812 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2813 |
object, extracts a character, if one is available, and assigns it to
|
| 2814 |
-
`c`.[^
|
| 2815 |
throw `ios_base::failure` ([[iostate.flags]])).
|
| 2816 |
|
| 2817 |
*Returns:* `*this`.
|
| 2818 |
|
| 2819 |
``` cpp
|
|
@@ -2822,11 +2864,11 @@ basic_istream<charT,traits>& get(char_type* s, streamsize n,
|
|
| 2822 |
```
|
| 2823 |
|
| 2824 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2825 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2826 |
object, extracts characters and stores them into successive locations of
|
| 2827 |
-
an array whose first element is designated by `s`.[^
|
| 2828 |
extracted and stored until any of the following occurs:
|
| 2829 |
|
| 2830 |
- `n` is less than one or `n - 1` characters are stored;
|
| 2831 |
- end-of-file occurs on the input sequence (in which case the function
|
| 2832 |
calls `setstate(eofbit)`);
|
|
@@ -2839,11 +2881,11 @@ if `n` is greater than zero it then stores a null character into the
|
|
| 2839 |
next successive location of the array.
|
| 2840 |
|
| 2841 |
*Returns:* `*this`.
|
| 2842 |
|
| 2843 |
``` cpp
|
| 2844 |
-
basic_istream<charT,traits>& get(char_type* s, streamsize n)
|
| 2845 |
```
|
| 2846 |
|
| 2847 |
*Effects:* Calls `get(s,n,widen(’\n’))`
|
| 2848 |
|
| 2849 |
*Returns:* Value returned by the call.
|
|
@@ -2886,25 +2928,25 @@ basic_istream<charT,traits>& getline(char_type* s, streamsize n,
|
|
| 2886 |
```
|
| 2887 |
|
| 2888 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2889 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2890 |
object, extracts characters and stores them into successive locations of
|
| 2891 |
-
an array whose first element is designated by `s`.[^
|
| 2892 |
extracted and stored until one of the following occurs:
|
| 2893 |
|
| 2894 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 2895 |
calls `setstate(eofbit)`);
|
| 2896 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 2897 |
(in which case the input character is extracted but not
|
| 2898 |
-
stored);[^
|
| 2899 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 2900 |
the function calls `setstate(failbit)`).
|
| 2901 |
|
| 2902 |
-
These conditions are tested in the order shown.[^
|
| 2903 |
|
| 2904 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 2905 |
-
(which may throw `ios_base::failure` ([[iostate.flags]])).[^
|
| 2906 |
|
| 2907 |
In any case, if `n` is greater than zero, it then stores a null
|
| 2908 |
character (using `charT()`) into the next successive location of the
|
| 2909 |
array.
|
| 2910 |
|
|
@@ -2949,12 +2991,12 @@ basic_istream<charT,traits>&
|
|
| 2949 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2950 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2951 |
object, extracts characters and discards them. Characters are extracted
|
| 2952 |
until any of the following occurs:
|
| 2953 |
|
| 2954 |
-
-
|
| 2955 |
-
characters
|
| 2956 |
- end-of-file occurs on the input sequence (in which case the function
|
| 2957 |
calls `setstate(eofbit)`, which may throw
|
| 2958 |
`ios_base::failure` ([[iostate.flags]]));
|
| 2959 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
| 2960 |
available input character `c` (in which case `c` is extracted).
|
|
@@ -2982,11 +3024,11 @@ basic_istream<charT,traits>& read(char_type* s, streamsize n);
|
|
| 2982 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2983 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2984 |
object, if `!good()` calls `setstate(failbit)` which may throw an
|
| 2985 |
exception, and return. Otherwise extracts characters and stores them
|
| 2986 |
into successive locations of an array whose first element is designated
|
| 2987 |
-
by `s`.[^
|
| 2988 |
following occurs:
|
| 2989 |
|
| 2990 |
- `n` characters are stored;
|
| 2991 |
- end-of-file occurs on the input sequence (in which case the function
|
| 2992 |
calls `setstate(failbit | eofbit)`, which may throw
|
|
@@ -3280,12 +3322,12 @@ namespace std {
|
|
| 3280 |
protected:
|
| 3281 |
basic_ostream(const basic_ostream& rhs) = delete;
|
| 3282 |
basic_ostream(basic_ostream&& rhs);
|
| 3283 |
|
| 3284 |
// [ostream.assign] Assign/swap
|
| 3285 |
-
basic_ostream& operator=(basic_ostream& rhs) = delete;
|
| 3286 |
-
basic_ostream& operator=(
|
| 3287 |
void swap(basic_ostream& rhs);
|
| 3288 |
};
|
| 3289 |
|
| 3290 |
// [ostream.inserters.character] character inserters
|
| 3291 |
template<class charT, class traits>
|
|
@@ -3382,11 +3424,11 @@ void swap(basic_ostream& rhs);
|
|
| 3382 |
|
| 3383 |
``` cpp
|
| 3384 |
namespace std {
|
| 3385 |
template <class charT,class traits = char_traits<charT> >
|
| 3386 |
class basic_ostream<charT,traits>::sentry {
|
| 3387 |
-
bool ok_; // exposition
|
| 3388 |
public:
|
| 3389 |
explicit sentry(basic_ostream<charT,traits>& os);
|
| 3390 |
~sentry();
|
| 3391 |
explicit operator bool() const { return ok_; }
|
| 3392 |
|
|
@@ -3402,16 +3444,16 @@ exception safe prefix and suffix operations.
|
|
| 3402 |
``` cpp
|
| 3403 |
explicit sentry(basic_ostream<charT,traits>& os);
|
| 3404 |
```
|
| 3405 |
|
| 3406 |
If `os.good()` is nonzero, prepares for formatted or unformatted output.
|
| 3407 |
-
If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^
|
| 3408 |
|
| 3409 |
If, after any preparation is completed, `os.good()` is `true`,
|
| 3410 |
`ok_ == true` otherwise, `ok_ == false`. During preparation, the
|
| 3411 |
constructor may call `setstate(failbit)` (which may throw
|
| 3412 |
-
`ios_base::failure` ([[iostate.flags]]))[^
|
| 3413 |
|
| 3414 |
``` cpp
|
| 3415 |
~sentry();
|
| 3416 |
```
|
| 3417 |
|
|
@@ -3442,11 +3484,13 @@ basic_ostream<charT,traits>& seekp(pos_type pos);
|
|
| 3442 |
``` cpp
|
| 3443 |
basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
|
| 3444 |
```
|
| 3445 |
|
| 3446 |
*Effects:* If `fail() != true`, executes
|
| 3447 |
-
`rdbuf()->pubseekoff(off, dir, ios_base::out)`.
|
|
|
|
|
|
|
| 3448 |
|
| 3449 |
*Returns:* `*this`.
|
| 3450 |
|
| 3451 |
#### Formatted output functions <a id="ostream.formatted">[[ostream.formatted]]</a>
|
| 3452 |
|
|
@@ -3456,19 +3500,28 @@ Each formatted output function begins execution by constructing an
|
|
| 3456 |
object of class `sentry`. If this object returns `true` when converted
|
| 3457 |
to a value of type `bool`, the function endeavors to generate the
|
| 3458 |
requested output. If the generation fails, then the formatted output
|
| 3459 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 3460 |
exception. If an exception is thrown during output, then `ios::badbit`
|
| 3461 |
-
is turned on[^
|
| 3462 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 3463 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 3464 |
leaving the formatted output function. If no exception is thrown, the
|
| 3465 |
result of the formatted output function is `*this`.
|
| 3466 |
|
| 3467 |
-
The descriptions of the individual formatted output
|
| 3468 |
how they perform output and do not mention the `sentry` object.
|
| 3469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3470 |
##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
|
| 3471 |
|
| 3472 |
``` cpp
|
| 3473 |
operator<<(bool val);
|
| 3474 |
operator<<(short val);
|
|
@@ -3540,11 +3593,11 @@ performed the following code fragment:
|
|
| 3540 |
|
| 3541 |
``` cpp
|
| 3542 |
bool failed = use_facet<
|
| 3543 |
num_put<charT,ostreambuf_iterator<charT,traits> >
|
| 3544 |
>(getloc()).put(*this, *this, fill(),
|
| 3545 |
-
static_cast<double>(
|
| 3546 |
```
|
| 3547 |
|
| 3548 |
The first argument provides an object of the `ostreambuf_iterator<>`
|
| 3549 |
class which is an iterator for class `basic_ostream<>`. It bypasses
|
| 3550 |
`ostream`s and uses `streambuf`s directly. Class `locale` relies on
|
|
@@ -3559,32 +3612,32 @@ from which to obtain other facets. If `failed` is `true` then does
|
|
| 3559 |
|
| 3560 |
##### `basic_ostream::operator<<` <a id="ostream.inserters">[[ostream.inserters]]</a>
|
| 3561 |
|
| 3562 |
``` cpp
|
| 3563 |
basic_ostream<charT,traits>& operator<<
|
| 3564 |
-
(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
|
| 3565 |
```
|
| 3566 |
|
| 3567 |
*Effects:* None. Does not behave as a formatted output function (as
|
| 3568 |
described in [[ostream.formatted.reqmts]]).
|
| 3569 |
|
| 3570 |
-
*Returns:* `pf(*this)`.[^
|
| 3571 |
|
| 3572 |
``` cpp
|
| 3573 |
basic_ostream<charT,traits>& operator<<
|
| 3574 |
-
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&))
|
| 3575 |
```
|
| 3576 |
|
| 3577 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 3578 |
formatted output function (as described
|
| 3579 |
in [[ostream.formatted.reqmts]]).
|
| 3580 |
|
| 3581 |
-
*Returns:* `*this`.[^
|
| 3582 |
|
| 3583 |
``` cpp
|
| 3584 |
basic_ostream<charT,traits>& operator<<
|
| 3585 |
-
(ios_base& (*pf)(ios_base&))
|
| 3586 |
```
|
| 3587 |
|
| 3588 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 3589 |
formatted output function (as described
|
| 3590 |
in [[ostream.formatted.reqmts]]).
|
|
@@ -3620,11 +3673,11 @@ caught exception is rethrown.
|
|
| 3620 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 3621 |
|
| 3622 |
``` cpp
|
| 3623 |
template<class charT, class traits>
|
| 3624 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 3625 |
-
charT c
|
| 3626 |
template<class charT, class traits>
|
| 3627 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 3628 |
char c);
|
| 3629 |
// specialization
|
| 3630 |
template<class traits>
|
|
@@ -3637,18 +3690,17 @@ template<class traits>
|
|
| 3637 |
template<class traits>
|
| 3638 |
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
|
| 3639 |
unsigned char c);
|
| 3640 |
```
|
| 3641 |
|
| 3642 |
-
*Effects:* Behaves
|
| 3643 |
-
|
| 3644 |
-
|
| 3645 |
-
|
| 3646 |
-
|
| 3647 |
-
|
| 3648 |
-
|
| 3649 |
-
into `out`.
|
| 3650 |
|
| 3651 |
*Returns:* `out`.
|
| 3652 |
|
| 3653 |
``` cpp
|
| 3654 |
template<class charT, class traits>
|
|
@@ -3669,13 +3721,14 @@ template<class traits>
|
|
| 3669 |
```
|
| 3670 |
|
| 3671 |
*Requires:* `s` shall not be a null pointer.
|
| 3672 |
|
| 3673 |
*Effects:* Behaves like a formatted inserter (as described
|
| 3674 |
-
in [[ostream.formatted.reqmts]]) of `out`.
|
| 3675 |
-
|
| 3676 |
-
|
|
|
|
| 3677 |
|
| 3678 |
- `traits::length(s)` for the overload where the first argument is of
|
| 3679 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 3680 |
`const charT*`, and also for the overload where the first argument is
|
| 3681 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
@@ -3684,24 +3737,23 @@ number that would be computed as if by:
|
|
| 3684 |
argument is of type `basic_ostream<charT, traits>&` and the second is
|
| 3685 |
of type `const char*`,
|
| 3686 |
- `traits::length(reinterpret_cast<const char*>(s))` for the other two
|
| 3687 |
overloads.
|
| 3688 |
|
| 3689 |
-
|
| 3690 |
-
`
|
| 3691 |
-
`
|
| 3692 |
-
required padding are inserted into `out`. Calls `width(0)`.
|
| 3693 |
|
| 3694 |
*Returns:* `out`.
|
| 3695 |
|
| 3696 |
#### Unformatted output functions <a id="ostream.unformatted">[[ostream.unformatted]]</a>
|
| 3697 |
|
| 3698 |
Each unformatted output function begins execution by constructing an
|
| 3699 |
object of class `sentry`. If this object returns `true`, while
|
| 3700 |
converting to a value of type `bool`, the function endeavors to generate
|
| 3701 |
the requested output. If an exception is thrown during output, then
|
| 3702 |
-
`ios::badbit` is turned on[^
|
| 3703 |
`(exceptions() & badbit) != 0` then the exception is rethrown. In any
|
| 3704 |
case, the unformatted output function ends by destroying the sentry
|
| 3705 |
object, then, if no exception was thrown, returning the value specified
|
| 3706 |
for the unformatted output function.
|
| 3707 |
|
|
@@ -3709,11 +3761,11 @@ for the unformatted output function.
|
|
| 3709 |
basic_ostream<charT,traits>& put(char_type c);
|
| 3710 |
```
|
| 3711 |
|
| 3712 |
*Effects:* Behaves as an unformatted output function (as described
|
| 3713 |
in [[ostream.unformatted]], paragraph 1). After constructing a sentry
|
| 3714 |
-
object, inserts the character `c`, if possible.[^
|
| 3715 |
|
| 3716 |
Otherwise, calls `setstate(badbit)` (which may throw
|
| 3717 |
`ios_base::failure` ([[iostate.flags]])).
|
| 3718 |
|
| 3719 |
*Returns:* `*this`.
|
|
@@ -3723,11 +3775,11 @@ basic_ostream& write(const char_type* s, streamsize n);
|
|
| 3723 |
```
|
| 3724 |
|
| 3725 |
*Effects:* Behaves as an unformatted output function (as described
|
| 3726 |
in [[ostream.unformatted]], paragraph 1). After constructing a sentry
|
| 3727 |
object, obtains characters to insert from successive locations of an
|
| 3728 |
-
array whose first element is designated by `s`.[^
|
| 3729 |
inserted until either of the following occurs:
|
| 3730 |
|
| 3731 |
- `n` characters are inserted;
|
| 3732 |
- inserting in the output sequence fails (in which case the function
|
| 3733 |
calls `setstate(badbit)`, which may throw
|
|
@@ -3811,11 +3863,11 @@ unspecified resetiosflags(ios_base::fmtflags mask);
|
|
| 3811 |
*Returns:* An object of unspecified type such that if `out` is an object
|
| 3812 |
of type `basic_ostream<charT, traits>` then the expression
|
| 3813 |
`out << resetiosflags(mask)` behaves as if it called `f(out, mask)`, or
|
| 3814 |
if `in` is an object of type `basic_istream<charT, traits>` then the
|
| 3815 |
expression `in >> resetiosflags(mask)` behaves as if it called
|
| 3816 |
-
`f(in, mask)`, where the function `f` is defined as:[^
|
| 3817 |
|
| 3818 |
``` cpp
|
| 3819 |
void f(ios_base& str, ios_base::fmtflags mask) {
|
| 3820 |
// reset specified flags
|
| 3821 |
str.setf(ios_base::fmtflags(0), mask);
|
|
@@ -4073,11 +4125,85 @@ void f(basic_ios<charT, traits>& str, const struct tm* tmb, const charT* fmt) {
|
|
| 4073 |
str.setstate(ios_base::badbit);
|
| 4074 |
}
|
| 4075 |
```
|
| 4076 |
|
| 4077 |
The expression `out << put_time(tmb, fmt)` shall have type
|
| 4078 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4079 |
|
| 4080 |
## String-based streams <a id="string.streams">[[string.streams]]</a>
|
| 4081 |
|
| 4082 |
### Overview <a id="string.streams.overview">[[string.streams.overview]]</a>
|
| 4083 |
|
|
@@ -4162,11 +4288,11 @@ namespace std {
|
|
| 4162 |
virtual pos_type seekpos(pos_type sp,
|
| 4163 |
ios_base::openmode which
|
| 4164 |
= ios_base::in | ios_base::out);
|
| 4165 |
|
| 4166 |
private:
|
| 4167 |
-
ios_base::openmode mode; // exposition
|
| 4168 |
};
|
| 4169 |
|
| 4170 |
template <class charT, class traits, class Allocator>
|
| 4171 |
void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
| 4172 |
basic_stringbuf<charT, traits, Allocator>& y);
|
|
@@ -4457,11 +4583,11 @@ namespace std {
|
|
| 4457 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4458 |
|
| 4459 |
basic_string<charT,traits,Allocator> str() const;
|
| 4460 |
void str(const basic_string<charT,traits,Allocator>& s);
|
| 4461 |
private:
|
| 4462 |
-
basic_stringbuf<charT,traits,Allocator> sb; // exposition
|
| 4463 |
};
|
| 4464 |
|
| 4465 |
template <class charT, class traits, class Allocator>
|
| 4466 |
void swap(basic_istringstream<charT, traits, Allocator>& x,
|
| 4467 |
basic_istringstream<charT, traits, Allocator>& y);
|
|
@@ -4587,11 +4713,11 @@ namespace std {
|
|
| 4587 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4588 |
|
| 4589 |
basic_string<charT,traits,Allocator> str() const;
|
| 4590 |
void str(const basic_string<charT,traits,Allocator>& s);
|
| 4591 |
private:
|
| 4592 |
-
basic_stringbuf<charT,traits,Allocator> sb; // exposition
|
| 4593 |
};
|
| 4594 |
|
| 4595 |
template <class charT, class traits, class Allocator>
|
| 4596 |
void swap(basic_ostringstream<charT, traits, Allocator>& x,
|
| 4597 |
basic_ostringstream<charT, traits, Allocator>& y);
|
|
@@ -4718,11 +4844,11 @@ namespace std {
|
|
| 4718 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4719 |
basic_string<charT,traits,Allocator> str() const;
|
| 4720 |
void str(const basic_string<charT,traits,Allocator>& str);
|
| 4721 |
|
| 4722 |
private:
|
| 4723 |
-
basic_stringbuf<charT, traits> sb; // exposition
|
| 4724 |
};
|
| 4725 |
|
| 4726 |
template <class charT, class traits, class Allocator>
|
| 4727 |
void swap(basic_stringstream<charT, traits, Allocator>& x,
|
| 4728 |
basic_stringstream<charT, traits, Allocator>& y);
|
|
@@ -4736,11 +4862,11 @@ and writing from objects of class
|
|
| 4736 |
associated sequence. For the sake of exposition, the maintained data is
|
| 4737 |
presented here as
|
| 4738 |
|
| 4739 |
- `sb`, the `stringbuf` object.
|
| 4740 |
|
| 4741 |
-
### basic_stringstream constructors <a id="stringstream.cons">[[stringstream.cons]]</a>
|
| 4742 |
|
| 4743 |
``` cpp
|
| 4744 |
explicit basic_stringstream(
|
| 4745 |
ios_base::openmode which = ios_base::out|ios_base::in);
|
| 4746 |
```
|
|
@@ -4794,11 +4920,11 @@ void swap(basic_stringstream<charT, traits, Allocator>& x,
|
|
| 4794 |
basic_stringstream<charT, traits, Allocator>& y);
|
| 4795 |
```
|
| 4796 |
|
| 4797 |
*Effects:* `x.swap(y)`.
|
| 4798 |
|
| 4799 |
-
### Member functions <a id="stringstream.members">[[stringstream.members]]</a>
|
| 4800 |
|
| 4801 |
``` cpp
|
| 4802 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4803 |
```
|
| 4804 |
|
|
@@ -5033,11 +5159,11 @@ basic_filebuf<charT,traits>* open(const char* s,
|
|
| 5033 |
|
| 5034 |
*Effects:* If `is_open() != false`, returns a null pointer. Otherwise,
|
| 5035 |
initializes the `filebuf` as required. It then opens a file, if
|
| 5036 |
possible, whose name is the NTBS`s` (as if by calling
|
| 5037 |
`std::fopen(s,modstr)`). The NTBS`modstr` is determined from
|
| 5038 |
-
`mode &
|
| 5039 |
Table [[tab:iostreams.file.open.modes]]. If `mode` is not some
|
| 5040 |
combination of flags shown in the table then the open fails.
|
| 5041 |
|
| 5042 |
**Table: File open modes** <a id="tab:iostreams.file.open.modes">[tab:iostreams.file.open.modes]</a>
|
| 5043 |
|
|
@@ -5062,11 +5188,11 @@ combination of flags shown in the table then the open fails.
|
|
| 5062 |
| + | + | | | + | `"a+b"` |
|
| 5063 |
|
| 5064 |
|
| 5065 |
If the open operation succeeds and `(mode & ios_base::ate) != 0`,
|
| 5066 |
positions the file to the end (as if by calling
|
| 5067 |
-
`std::fseek(file,0,SEEK_END)`).[^
|
| 5068 |
|
| 5069 |
If the repositioning operation fails, calls `close()` and returns a null
|
| 5070 |
pointer to indicate failure.
|
| 5071 |
|
| 5072 |
*Returns:* `this` if successful, a null pointer otherwise.
|
|
@@ -5088,11 +5214,11 @@ last virtual member function called on `*this` (between `underflow`,
|
|
| 5088 |
`overflow`, `seekoff`, and `seekpos`) was `overflow` then calls
|
| 5089 |
`a_codecvt.unshift` (possibly several times) to determine a termination
|
| 5090 |
sequence, inserts those characters and calls `overflow(traits::eof())`
|
| 5091 |
again. Finally, regardless of whether any of the preceding calls fails
|
| 5092 |
or throws an exception, the function closes the file (as if by calling
|
| 5093 |
-
`std::fclose(file)`).[^
|
| 5094 |
including `std::fclose`, fails, `close` fails by returning a null
|
| 5095 |
pointer. If one of these calls throws an exception, the exception is
|
| 5096 |
caught and rethrown after closing the file.
|
| 5097 |
|
| 5098 |
*Returns:* `this` on success, a null pointer otherwise.
|
|
@@ -5338,11 +5464,11 @@ namespace std {
|
|
| 5338 |
bool is_open() const;
|
| 5339 |
void open(const char* s, ios_base::openmode mode = ios_base::in);
|
| 5340 |
void open(const string& s, ios_base::openmode mode = ios_base::in);
|
| 5341 |
void close();
|
| 5342 |
private:
|
| 5343 |
-
basic_filebuf<charT,traits> sb; // exposition
|
| 5344 |
};
|
| 5345 |
|
| 5346 |
template <class charT, class traits>
|
| 5347 |
void swap(basic_ifstream<charT, traits>& x,
|
| 5348 |
basic_ifstream<charT, traits>& y);
|
|
@@ -5490,11 +5616,11 @@ namespace std {
|
|
| 5490 |
bool is_open() const;
|
| 5491 |
void open(const char* s, ios_base::openmode mode = ios_base::out);
|
| 5492 |
void open(const string& s, ios_base::openmode mode = ios_base::out);
|
| 5493 |
void close();
|
| 5494 |
private:
|
| 5495 |
-
basic_filebuf<charT,traits> sb; // exposition
|
| 5496 |
};
|
| 5497 |
|
| 5498 |
template <class charT, class traits>
|
| 5499 |
void swap(basic_ofstream<charT, traits>& x,
|
| 5500 |
basic_ofstream<charT, traits>& y);
|
|
@@ -5646,11 +5772,11 @@ namespace std {
|
|
| 5646 |
void open(const string& s,
|
| 5647 |
ios_base::openmode mode = ios_base::in|ios_base::out);
|
| 5648 |
void close();
|
| 5649 |
|
| 5650 |
private:
|
| 5651 |
-
basic_filebuf<charT,traits> sb; // exposition
|
| 5652 |
};
|
| 5653 |
|
| 5654 |
template <class charT, class traits>
|
| 5655 |
void swap(basic_fstream<charT, traits>& x,
|
| 5656 |
basic_fstream<charT, traits>& y);
|
|
@@ -5766,11 +5892,12 @@ void close();
|
|
| 5766 |
returns a null pointer, calls `setstate(failbit)` ([[iostate.flags]])
|
| 5767 |
(which may throw `ios_base::failure`).
|
| 5768 |
|
| 5769 |
### C library files <a id="c.files">[[c.files]]</a>
|
| 5770 |
|
| 5771 |
-
Table [[tab:iostreams.hdr.cstdio]] describes header `<cstdio>`.
|
|
|
|
| 5772 |
|
| 5773 |
Calls to the function `tmpnam` with an argument of `NULL` may introduce
|
| 5774 |
a data race ([[res.on.data.races]]) with other calls to `tmpnam` with
|
| 5775 |
an argument of `NULL`.
|
| 5776 |
|
|
@@ -5807,11 +5934,10 @@ Library header `<inttypes.h>`, with the following changes:
|
|
| 5807 |
[bitmask.types]: library.md#bitmask.types
|
| 5808 |
[c.files]: #c.files
|
| 5809 |
[enumerated.types]: library.md#enumerated.types
|
| 5810 |
[error.reporting]: #error.reporting
|
| 5811 |
[ext.manip]: #ext.manip
|
| 5812 |
-
[facet.num.put.virtuals]: localization.md#facet.num.put.virtuals
|
| 5813 |
[fig:streampos]: #fig:streampos
|
| 5814 |
[file.streams]: #file.streams
|
| 5815 |
[filebuf]: #filebuf
|
| 5816 |
[filebuf.assign]: #filebuf.assign
|
| 5817 |
[filebuf.cons]: #filebuf.cons
|
|
@@ -5906,10 +6032,11 @@ Library header `<inttypes.h>`, with the following changes:
|
|
| 5906 |
[ostringstream]: #ostringstream
|
| 5907 |
[ostringstream.assign]: #ostringstream.assign
|
| 5908 |
[ostringstream.cons]: #ostringstream.cons
|
| 5909 |
[ostringstream.members]: #ostringstream.members
|
| 5910 |
[output.streams]: #output.streams
|
|
|
|
| 5911 |
[res.on.data.races]: library.md#res.on.data.races
|
| 5912 |
[res.on.exception.handling]: library.md#res.on.exception.handling
|
| 5913 |
[std.ios.manip]: #std.ios.manip
|
| 5914 |
[std.manip]: #std.manip
|
| 5915 |
[stream.buffers]: #stream.buffers
|
|
@@ -6019,81 +6146,85 @@ Library header `<inttypes.h>`, with the following changes:
|
|
| 6019 |
|
| 6020 |
[^15]: Classes derived from `basic_streambuf` can provide more efficient
|
| 6021 |
ways to implement `xsgetn()` and `xsputn()` by overriding these
|
| 6022 |
definitions from the base class.
|
| 6023 |
|
| 6024 |
-
[^16]:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6025 |
library. The semantics of the constructor used in user code is as
|
| 6026 |
specified.
|
| 6027 |
|
| 6028 |
-
[^
|
| 6029 |
implementation-dependent operations.
|
| 6030 |
|
| 6031 |
-
[^
|
| 6032 |
-
|
| 6033 |
-
[^19]: See, for example, the function signature
|
| 6034 |
-
`ws(basic_istream&)` ([[istream.manip]]).
|
| 6035 |
|
| 6036 |
[^20]: See, for example, the function signature
|
|
|
|
|
|
|
|
|
|
| 6037 |
`dec(ios_base&)` ([[basefield.manip]]).
|
| 6038 |
|
| 6039 |
-
[^
|
| 6040 |
-
|
| 6041 |
-
[^22]: Note that this function is not overloaded on types `signed char`
|
| 6042 |
-
and `unsigned char`.
|
| 6043 |
|
| 6044 |
[^23]: Note that this function is not overloaded on types `signed char`
|
| 6045 |
and `unsigned char`.
|
| 6046 |
|
| 6047 |
[^24]: Note that this function is not overloaded on types `signed char`
|
| 6048 |
and `unsigned char`.
|
| 6049 |
|
| 6050 |
-
[^25]:
|
|
|
|
|
|
|
|
|
|
| 6051 |
the `gcount()`, even though it is not stored.
|
| 6052 |
|
| 6053 |
-
[^
|
| 6054 |
setting `failbit`. This is different behavior than the historical
|
| 6055 |
AT&T implementation.
|
| 6056 |
|
| 6057 |
-
[^
|
| 6058 |
set.
|
| 6059 |
|
| 6060 |
-
[^
|
| 6061 |
and `unsigned char`.
|
| 6062 |
|
| 6063 |
-
[^
|
| 6064 |
function can determine that no synchronization is necessary.
|
| 6065 |
|
| 6066 |
-
[^
|
| 6067 |
additional implementation-dependent operations.
|
| 6068 |
|
| 6069 |
-
[^
|
| 6070 |
-
|
| 6071 |
-
[^32]: See, for example, the function signature
|
| 6072 |
-
`endl(basic_ostream&)` ([[ostream.manip]]).
|
| 6073 |
|
| 6074 |
[^33]: See, for example, the function signature
|
|
|
|
|
|
|
|
|
|
| 6075 |
`dec(ios_base&)` ([[basefield.manip]]).
|
| 6076 |
|
| 6077 |
-
[^
|
| 6078 |
-
|
| 6079 |
-
[^35]: Note that this function is not overloaded on types `signed char`
|
| 6080 |
-
and `unsigned char`.
|
| 6081 |
|
| 6082 |
[^36]: Note that this function is not overloaded on types `signed char`
|
| 6083 |
and `unsigned char`.
|
| 6084 |
|
| 6085 |
-
[^37]:
|
|
|
|
|
|
|
|
|
|
| 6086 |
`ios_base::skipws` in the format flags stored in the
|
| 6087 |
`basic_istream<charT,traits>` object `cin` (the same as
|
| 6088 |
`cin >>noskipws`), and the expression
|
| 6089 |
`cout << resetiosflags(ios_base::showbase)` clears
|
| 6090 |
`ios_base::showbase` in the format flags stored in the
|
| 6091 |
`basic_ostream<charT,traits>` object `cout` (the same as
|
| 6092 |
`cout <<noshowbase`).
|
| 6093 |
|
| 6094 |
-
[^
|
| 6095 |
`fopen(const char*, const char*)` and `fseek(FILE*, long, int)` are
|
| 6096 |
declared, in `<cstdio>` ([[c.files]]).
|
| 6097 |
|
| 6098 |
-
[^
|
| 6099 |
([[c.files]]).
|
|
|
|
| 55 |
and `traits` behave as described if `traits::pos_type` and
|
| 56 |
`traits::off_type` are `streampos` and `streamoff` respectively. Except
|
| 57 |
as noted explicitly below, their behavior when `traits::pos_type` and
|
| 58 |
`traits::off_type` are other types is *implementation-defined*.
|
| 59 |
|
| 60 |
+
In the classes of Clause [[input.output]], a template parameter with
|
| 61 |
+
name `charT` represents a member of the set of types containing `char`,
|
| 62 |
+
`wchar_t`, and any other implementation-defined character types that
|
| 63 |
+
satisfy the requirements for a character on which any of the iostream
|
| 64 |
+
components can be instantiated.
|
| 65 |
|
| 66 |
### Thread safety <a id="iostreams.threadsafety">[[iostreams.threadsafety]]</a>
|
| 67 |
|
| 68 |
Concurrent access to a stream object ([[string.streams]],
|
| 69 |
[[file.streams]]), stream buffer object ([[stream.buffers]]), or C
|
|
|
|
| 400 |
enum class io_errc {
|
| 401 |
stream = 1
|
| 402 |
};
|
| 403 |
|
| 404 |
template <> struct is_error_code_enum<io_errc> : public true_type { };
|
| 405 |
+
error_code make_error_code(io_errc e) noexcept;
|
| 406 |
+
error_condition make_error_condition(io_errc e) noexcept;
|
| 407 |
+
const error_category& iostream_category() noexcept;
|
| 408 |
}
|
| 409 |
```
|
| 410 |
|
| 411 |
### Types <a id="stream.types">[[stream.types]]</a>
|
| 412 |
|
|
|
|
| 471 |
static constexpr openmode out = unspecified;
|
| 472 |
static constexpr openmode trunc = unspecified;
|
| 473 |
|
| 474 |
// [ios::seekdir] seekdir
|
| 475 |
typedef T4 seekdir;
|
| 476 |
+
static constexpr seekdir beg = unspecified;
|
| 477 |
+
static constexpr seekdir cur = unspecified;
|
| 478 |
+
static constexpr seekdir end = unspecified;
|
| 479 |
|
| 480 |
class Init;
|
| 481 |
|
| 482 |
// [fmtflags.state] fmtflags state:
|
| 483 |
fmtflags flags() const;
|
|
|
|
| 515 |
|
| 516 |
protected:
|
| 517 |
ios_base();
|
| 518 |
|
| 519 |
private:
|
| 520 |
+
static int index; // exposition only
|
| 521 |
+
long* iarray; // exposition only
|
| 522 |
+
void** parray; // exposition only
|
| 523 |
};
|
| 524 |
}
|
| 525 |
```
|
| 526 |
|
| 527 |
`ios_base`
|
|
|
|
| 577 |
stream library would typically be reported as
|
| 578 |
`error_code(io_errc::stream,
|
| 579 |
iostream_category())`.
|
| 580 |
|
| 581 |
``` cpp
|
| 582 |
+
explicit failure(const string& msg, const error_code& ec = io_errc::stream);
|
| 583 |
```
|
| 584 |
|
| 585 |
*Effects:* Constructs an object of class `failure` by constructing the
|
| 586 |
base class with `msg` and `ec`.
|
| 587 |
|
|
|
|
| 704 |
class ios_base::Init {
|
| 705 |
public:
|
| 706 |
Init();
|
| 707 |
~Init();
|
| 708 |
private:
|
| 709 |
+
static int init_cnt; // exposition only
|
| 710 |
};
|
| 711 |
}
|
| 712 |
```
|
| 713 |
|
| 714 |
The class `Init` describes an object whose construction ensures the
|
|
|
|
| 869 |
```
|
| 870 |
|
| 871 |
is the same as the effect of
|
| 872 |
|
| 873 |
``` cpp
|
| 874 |
+
c = str.rdbuf()->sbumpc();
|
| 875 |
```
|
| 876 |
|
| 877 |
for any sequences of characters; and the effect of pushing back a
|
| 878 |
character `c` by
|
| 879 |
|
|
|
|
| 895 |
static int xalloc();
|
| 896 |
```
|
| 897 |
|
| 898 |
*Returns:* `index` `++`.
|
| 899 |
|
| 900 |
+
*Remarks:* Concurrent access to this function by multiple threads shall
|
| 901 |
+
not result in a data race ([[intro.multithread]]).
|
| 902 |
+
|
| 903 |
``` cpp
|
| 904 |
long& iword(int idx);
|
| 905 |
```
|
| 906 |
|
| 907 |
*Effects:* If `iarray` is a null pointer, allocates an array of `long`
|
|
|
|
| 971 |
construction. The object’s members shall be initialized by calling
|
| 972 |
`basic_ios::init` before the object’s first use or before it is
|
| 973 |
destroyed, whichever comes first; otherwise the behavior is undefined.
|
| 974 |
|
| 975 |
``` cpp
|
| 976 |
+
~ios_base();
|
| 977 |
```
|
| 978 |
|
| 979 |
*Effects:* Destroys an object of class `ios_base`. Calls each registered
|
| 980 |
callback pair `(fn, index)` ([[ios.base.callback]]) as
|
| 981 |
`(*fn)(erase_event, *this, index)` at such time that any `ios_base`
|
|
|
|
| 989 |
public:
|
| 990 |
// [fpos.members] Members
|
| 991 |
stateT state() const;
|
| 992 |
void state(stateT);
|
| 993 |
private;
|
| 994 |
+
stateT st; // exposition only
|
| 995 |
};
|
| 996 |
}
|
| 997 |
```
|
| 998 |
|
| 999 |
#### `fpos` members <a id="fpos.members">[[fpos.members]]</a>
|
|
|
|
| 1589 |
*Returns:* `str`.
|
| 1590 |
|
| 1591 |
#### Error reporting <a id="error.reporting">[[error.reporting]]</a>
|
| 1592 |
|
| 1593 |
``` cpp
|
| 1594 |
+
error_code make_error_code(io_errc e) noexcept;
|
| 1595 |
```
|
| 1596 |
|
| 1597 |
*Returns:* `error_code(static_cast<int>(e), iostream_category())`.
|
| 1598 |
|
| 1599 |
``` cpp
|
| 1600 |
+
error_condition make_error_condition(io_errc e) noexcept;
|
| 1601 |
```
|
| 1602 |
|
| 1603 |
*Returns:* `error_condition(static_cast<int>(e), iostream_category())`.
|
| 1604 |
|
| 1605 |
``` cpp
|
| 1606 |
+
const error_category& iostream_category() noexcept;
|
| 1607 |
```
|
| 1608 |
|
| 1609 |
*Returns:* A reference to an object of a type derived from class
|
| 1610 |
`error_category`.
|
| 1611 |
|
|
|
|
| 2050 |
#### `basic_streambuf` virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
|
| 2051 |
|
| 2052 |
##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
|
| 2053 |
|
| 2054 |
``` cpp
|
| 2055 |
+
void imbue(const locale&);
|
| 2056 |
```
|
| 2057 |
|
| 2058 |
*Effects:* Change any translations based on locale.
|
| 2059 |
|
| 2060 |
*Remarks:* Allows the derived class to be informed of changes in locale
|
|
|
|
| 2206 |
modifications that
|
| 2207 |
|
| 2208 |
- If `traits::eq_int_type(c,traits::eof())` returns `true`, then the
|
| 2209 |
input sequence is backed up one character before the pending sequence
|
| 2210 |
is determined.
|
| 2211 |
+
- If `traits::eq_int_type(c,traits::eof())` returns `false`, then `c` is
|
| 2212 |
prepended. Whether the input sequence is backed up or modified in any
|
| 2213 |
other way is unspecified.
|
| 2214 |
|
| 2215 |
On return, the constraints of `gptr()`, `eback()`, and `pptr()` are the
|
| 2216 |
same as for `underflow()`.
|
|
|
|
| 2228 |
|
| 2229 |
``` cpp
|
| 2230 |
streamsize xsputn(const char_type* s, streamsize n);
|
| 2231 |
```
|
| 2232 |
|
| 2233 |
+
*Effects:* Writes up to `n` characters to the output sequence as if by
|
| 2234 |
+
repeated calls to `sputc(c)`. The characters written are obtained from
|
| 2235 |
+
successive elements of the array whose first element is designated by
|
| 2236 |
+
`s`. Writing stops when either `n` characters have been written or a
|
| 2237 |
+
call to `sputc(c)` would return `traits::eof()`. Is is unspecified
|
| 2238 |
+
whether the function calls `overflow()` when `pptr() == epptr()` becomes
|
| 2239 |
+
true or whether it achieves the same effects by other means.
|
| 2240 |
+
|
| 2241 |
+
*Returns:* The number of characters written.
|
| 2242 |
+
|
| 2243 |
``` cpp
|
| 2244 |
int_type overflow(int_type c = traits::eof());
|
| 2245 |
```
|
| 2246 |
|
| 2247 |
+
*Effects:* Consumes some initial subsequence of the characters of the
|
| 2248 |
+
*pending sequence*. The pending sequence is defined as the concatenation
|
| 2249 |
+
of
|
| 2250 |
+
|
| 2251 |
+
*Remarks:* The member functions `sputc()` and `sputn()` call this
|
| 2252 |
+
function in case that no room can be found in the put buffer enough to
|
| 2253 |
+
accommodate the argument character sequence.
|
| 2254 |
+
|
| 2255 |
+
*Requires:* Every overriding definition of this virtual function shall
|
| 2256 |
+
obey the following constraints:
|
| 2257 |
+
|
| 2258 |
+
*Returns:* `traits::eof()` or throws an exception if the function fails.
|
| 2259 |
+
|
| 2260 |
+
Otherwise, returns some value other than `traits::eof()` to indicate
|
| 2261 |
+
success.[^16]
|
| 2262 |
+
|
| 2263 |
+
*Default behavior:* Returns `traits::eof()`.
|
| 2264 |
+
|
| 2265 |
## Formatting and manipulators <a id="iostream.format">[[iostream.format]]</a>
|
| 2266 |
|
| 2267 |
### Overview <a id="iostream.format.overview">[[iostream.format.overview]]</a>
|
| 2268 |
|
| 2269 |
\synopsis{Header \texttt{\<istream\>} synopsis}
|
|
|
|
| 2320 |
T6 setw(int n);
|
| 2321 |
template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
|
| 2322 |
template <class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
|
| 2323 |
template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
|
| 2324 |
template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
|
| 2325 |
+
|
| 2326 |
+
template <class charT>
|
| 2327 |
+
T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\'));
|
| 2328 |
+
|
| 2329 |
+
template <class charT, class traits, class Allocator>
|
| 2330 |
+
T12 quoted(const basic_string<charT, traits, Allocator>& s,
|
| 2331 |
+
charT delim=charT('"'), charT escape=charT('\\'));
|
| 2332 |
+
|
| 2333 |
+
template <class charT, class traits, class Allocator>
|
| 2334 |
+
T13 quoted(basic_string<charT, traits, Allocator>& s,
|
| 2335 |
+
charT delim=charT('"'), charT escape=charT('\\'));
|
| 2336 |
}
|
| 2337 |
```
|
| 2338 |
|
| 2339 |
### Input streams <a id="input.streams">[[input.streams]]</a>
|
| 2340 |
|
|
|
|
| 2523 |
``` cpp
|
| 2524 |
namespace std {
|
| 2525 |
template <class charT,class traits = char_traits<charT> >
|
| 2526 |
class basic_istream<charT,traits>::sentry {
|
| 2527 |
typedef traits traits_type;
|
| 2528 |
+
bool ok_; // exposition only
|
| 2529 |
public:
|
| 2530 |
explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
|
| 2531 |
~sentry();
|
| 2532 |
explicit operator bool() const { return ok_; }
|
| 2533 |
sentry(const sentry&) = delete;
|
|
|
|
| 2541 |
|
| 2542 |
``` cpp
|
| 2543 |
explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
|
| 2544 |
```
|
| 2545 |
|
| 2546 |
+
*Effects:* If `is.good()` is `false`, calls `is.setstate(failbit)`.
|
| 2547 |
Otherwise, prepares for formatted or unformatted input. First, if
|
| 2548 |
`is.tie()` is not a null pointer, the function calls `is.tie()->flush()`
|
| 2549 |
to synchronize the output sequence with any associated external C
|
| 2550 |
stream. Except that this call can be suppressed if the put area of
|
| 2551 |
`is.tie()` is empty. Further an implementation is allowed to defer the
|
| 2552 |
call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
|
| 2553 |
such call occurs before the `sentry` object is destroyed, the call to
|
| 2554 |
+
`flush` may be eliminated entirely.[^17] If `noskipws` is zero and
|
| 2555 |
`is.flags() & ios_base::skipws` is nonzero, the function extracts and
|
| 2556 |
discards each character as long as the next available input character
|
| 2557 |
`c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
|
| 2558 |
`is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
|
| 2559 |
`setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
|
|
|
|
| 2573 |
```
|
| 2574 |
|
| 2575 |
If, after any preparation is completed, `is.good()` is `true`,
|
| 2576 |
`ok_ != false` otherwise, `ok_ == false`. During preparation, the
|
| 2577 |
constructor may call `setstate(failbit)` (which may throw
|
| 2578 |
+
`ios_base::failure` ([[iostate.flags]]))[^18]
|
| 2579 |
|
| 2580 |
``` cpp
|
| 2581 |
~sentry();
|
| 2582 |
```
|
| 2583 |
|
|
|
|
| 2595 |
|
| 2596 |
Each formatted input function begins execution by constructing an object
|
| 2597 |
of class `sentry` with the `noskipws` (second) argument `false`. If the
|
| 2598 |
`sentry` object returns `true`, when converted to a value of type
|
| 2599 |
`bool`, the function endeavors to obtain the requested input. If an
|
| 2600 |
+
exception is thrown during input then `ios::badbit` is turned on[^19] in
|
| 2601 |
`*this`’s error state. If `(exceptions()&badbit) != 0` then the
|
| 2602 |
exception is rethrown. In any case, the formatted input function
|
| 2603 |
destroys the `sentry` object. If no exception has been thrown, it
|
| 2604 |
returns `*this`.
|
| 2605 |
|
|
|
|
| 2688 |
|
| 2689 |
##### `basic_istream::operator>>` <a id="istream::extractors">[[istream::extractors]]</a>
|
| 2690 |
|
| 2691 |
``` cpp
|
| 2692 |
basic_istream<charT,traits>& operator>>
|
| 2693 |
+
(basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&));
|
| 2694 |
```
|
| 2695 |
|
| 2696 |
*Effects:* None. This extractor does not behave as a formatted input
|
| 2697 |
function (as described in [[istream.formatted.reqmts]].)
|
| 2698 |
|
| 2699 |
+
*Returns:* `pf(*this)`.[^20]
|
| 2700 |
|
| 2701 |
``` cpp
|
| 2702 |
basic_istream<charT,traits>& operator>>
|
| 2703 |
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
|
| 2704 |
```
|
|
|
|
| 2712 |
``` cpp
|
| 2713 |
basic_istream<charT,traits>& operator>>
|
| 2714 |
(ios_base& (*pf)(ios_base&));
|
| 2715 |
```
|
| 2716 |
|
| 2717 |
+
*Effects:* Calls `pf(*this)`.[^21] This extractor does not behave as a
|
| 2718 |
formatted input function (as described
|
| 2719 |
in [[istream.formatted.reqmts]]).
|
| 2720 |
|
| 2721 |
*Returns:* `*this`.
|
| 2722 |
|
|
|
|
| 2814 |
value of type `bool`, the function returns without attempting to obtain
|
| 2815 |
any input. In either case the number of extracted characters is set to
|
| 2816 |
0; unformatted input functions taking a character array of non-zero size
|
| 2817 |
as an argument shall also store a null character (using `charT()`) in
|
| 2818 |
the first location of the array. If an exception is thrown during input
|
| 2819 |
+
then `ios::badbit` is turned on[^22] in `*this`’s error state.
|
| 2820 |
(Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 2821 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 2822 |
rethrown. It also counts the number of characters extracted. If no
|
| 2823 |
exception has been thrown it ends by storing the count in a member
|
| 2824 |
object and returning the value specified. In any event the `sentry`
|
|
|
|
| 2851 |
```
|
| 2852 |
|
| 2853 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2854 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2855 |
object, extracts a character, if one is available, and assigns it to
|
| 2856 |
+
`c`.[^23] Otherwise, the function calls `setstate(failbit)` (which may
|
| 2857 |
throw `ios_base::failure` ([[iostate.flags]])).
|
| 2858 |
|
| 2859 |
*Returns:* `*this`.
|
| 2860 |
|
| 2861 |
``` cpp
|
|
|
|
| 2864 |
```
|
| 2865 |
|
| 2866 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2867 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2868 |
object, extracts characters and stores them into successive locations of
|
| 2869 |
+
an array whose first element is designated by `s`.[^24] Characters are
|
| 2870 |
extracted and stored until any of the following occurs:
|
| 2871 |
|
| 2872 |
- `n` is less than one or `n - 1` characters are stored;
|
| 2873 |
- end-of-file occurs on the input sequence (in which case the function
|
| 2874 |
calls `setstate(eofbit)`);
|
|
|
|
| 2881 |
next successive location of the array.
|
| 2882 |
|
| 2883 |
*Returns:* `*this`.
|
| 2884 |
|
| 2885 |
``` cpp
|
| 2886 |
+
basic_istream<charT,traits>& get(char_type* s, streamsize n);
|
| 2887 |
```
|
| 2888 |
|
| 2889 |
*Effects:* Calls `get(s,n,widen(’\n’))`
|
| 2890 |
|
| 2891 |
*Returns:* Value returned by the call.
|
|
|
|
| 2928 |
```
|
| 2929 |
|
| 2930 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2931 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2932 |
object, extracts characters and stores them into successive locations of
|
| 2933 |
+
an array whose first element is designated by `s`.[^25] Characters are
|
| 2934 |
extracted and stored until one of the following occurs:
|
| 2935 |
|
| 2936 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 2937 |
calls `setstate(eofbit)`);
|
| 2938 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 2939 |
(in which case the input character is extracted but not
|
| 2940 |
+
stored);[^26]
|
| 2941 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 2942 |
the function calls `setstate(failbit)`).
|
| 2943 |
|
| 2944 |
+
These conditions are tested in the order shown.[^27]
|
| 2945 |
|
| 2946 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 2947 |
+
(which may throw `ios_base::failure` ([[iostate.flags]])).[^28]
|
| 2948 |
|
| 2949 |
In any case, if `n` is greater than zero, it then stores a null
|
| 2950 |
character (using `charT()`) into the next successive location of the
|
| 2951 |
array.
|
| 2952 |
|
|
|
|
| 2991 |
*Effects:* Behaves as an unformatted input function (as described
|
| 2992 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 2993 |
object, extracts characters and discards them. Characters are extracted
|
| 2994 |
until any of the following occurs:
|
| 2995 |
|
| 2996 |
+
- `n != numeric_limits<streamsize>::max()` ([[limits]]) and `n`
|
| 2997 |
+
characters have been extracted so far
|
| 2998 |
- end-of-file occurs on the input sequence (in which case the function
|
| 2999 |
calls `setstate(eofbit)`, which may throw
|
| 3000 |
`ios_base::failure` ([[iostate.flags]]));
|
| 3001 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
| 3002 |
available input character `c` (in which case `c` is extracted).
|
|
|
|
| 3024 |
*Effects:* Behaves as an unformatted input function (as described
|
| 3025 |
in [[istream.unformatted]], paragraph 1). After constructing a sentry
|
| 3026 |
object, if `!good()` calls `setstate(failbit)` which may throw an
|
| 3027 |
exception, and return. Otherwise extracts characters and stores them
|
| 3028 |
into successive locations of an array whose first element is designated
|
| 3029 |
+
by `s`.[^29] Characters are extracted and stored until either of the
|
| 3030 |
following occurs:
|
| 3031 |
|
| 3032 |
- `n` characters are stored;
|
| 3033 |
- end-of-file occurs on the input sequence (in which case the function
|
| 3034 |
calls `setstate(failbit | eofbit)`, which may throw
|
|
|
|
| 3322 |
protected:
|
| 3323 |
basic_ostream(const basic_ostream& rhs) = delete;
|
| 3324 |
basic_ostream(basic_ostream&& rhs);
|
| 3325 |
|
| 3326 |
// [ostream.assign] Assign/swap
|
| 3327 |
+
basic_ostream& operator=(const basic_ostream& rhs) = delete;
|
| 3328 |
+
basic_ostream& operator=(basic_ostream&& rhs);
|
| 3329 |
void swap(basic_ostream& rhs);
|
| 3330 |
};
|
| 3331 |
|
| 3332 |
// [ostream.inserters.character] character inserters
|
| 3333 |
template<class charT, class traits>
|
|
|
|
| 3424 |
|
| 3425 |
``` cpp
|
| 3426 |
namespace std {
|
| 3427 |
template <class charT,class traits = char_traits<charT> >
|
| 3428 |
class basic_ostream<charT,traits>::sentry {
|
| 3429 |
+
bool ok_; // exposition only
|
| 3430 |
public:
|
| 3431 |
explicit sentry(basic_ostream<charT,traits>& os);
|
| 3432 |
~sentry();
|
| 3433 |
explicit operator bool() const { return ok_; }
|
| 3434 |
|
|
|
|
| 3444 |
``` cpp
|
| 3445 |
explicit sentry(basic_ostream<charT,traits>& os);
|
| 3446 |
```
|
| 3447 |
|
| 3448 |
If `os.good()` is nonzero, prepares for formatted or unformatted output.
|
| 3449 |
+
If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^30]
|
| 3450 |
|
| 3451 |
If, after any preparation is completed, `os.good()` is `true`,
|
| 3452 |
`ok_ == true` otherwise, `ok_ == false`. During preparation, the
|
| 3453 |
constructor may call `setstate(failbit)` (which may throw
|
| 3454 |
+
`ios_base::failure` ([[iostate.flags]]))[^31]
|
| 3455 |
|
| 3456 |
``` cpp
|
| 3457 |
~sentry();
|
| 3458 |
```
|
| 3459 |
|
|
|
|
| 3484 |
``` cpp
|
| 3485 |
basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
|
| 3486 |
```
|
| 3487 |
|
| 3488 |
*Effects:* If `fail() != true`, executes
|
| 3489 |
+
`rdbuf()->pubseekoff(off, dir, ios_base::out)`. In case of failure, the
|
| 3490 |
+
function calls `setstate(failbit)` (which may throw
|
| 3491 |
+
`ios_base::failure`).
|
| 3492 |
|
| 3493 |
*Returns:* `*this`.
|
| 3494 |
|
| 3495 |
#### Formatted output functions <a id="ostream.formatted">[[ostream.formatted]]</a>
|
| 3496 |
|
|
|
|
| 3500 |
object of class `sentry`. If this object returns `true` when converted
|
| 3501 |
to a value of type `bool`, the function endeavors to generate the
|
| 3502 |
requested output. If the generation fails, then the formatted output
|
| 3503 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 3504 |
exception. If an exception is thrown during output, then `ios::badbit`
|
| 3505 |
+
is turned on[^32] in `*this`’s error state. If
|
| 3506 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 3507 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 3508 |
leaving the formatted output function. If no exception is thrown, the
|
| 3509 |
result of the formatted output function is `*this`.
|
| 3510 |
|
| 3511 |
+
The descriptions of the individual formatted output functions describe
|
| 3512 |
how they perform output and do not mention the `sentry` object.
|
| 3513 |
|
| 3514 |
+
If a formatted output function of a stream `os` determines padding, it
|
| 3515 |
+
does so as follows. Given a `charT` character sequence `seq` where
|
| 3516 |
+
`charT` is the character type of the stream, if the length of `seq` is
|
| 3517 |
+
less than `os.width()`, then enough copies of `os.fill()` are added to
|
| 3518 |
+
this sequence as necessary to pad to a width of `os.width()` characters.
|
| 3519 |
+
If `(os.flags() & ios_base::adjustfield) == ios_base::left` is `true`,
|
| 3520 |
+
the fill characters are placed after the character sequence; otherwise,
|
| 3521 |
+
they are placed before the character sequence.
|
| 3522 |
+
|
| 3523 |
##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
|
| 3524 |
|
| 3525 |
``` cpp
|
| 3526 |
operator<<(bool val);
|
| 3527 |
operator<<(short val);
|
|
|
|
| 3593 |
|
| 3594 |
``` cpp
|
| 3595 |
bool failed = use_facet<
|
| 3596 |
num_put<charT,ostreambuf_iterator<charT,traits> >
|
| 3597 |
>(getloc()).put(*this, *this, fill(),
|
| 3598 |
+
static_cast<double>(val)).failed();
|
| 3599 |
```
|
| 3600 |
|
| 3601 |
The first argument provides an object of the `ostreambuf_iterator<>`
|
| 3602 |
class which is an iterator for class `basic_ostream<>`. It bypasses
|
| 3603 |
`ostream`s and uses `streambuf`s directly. Class `locale` relies on
|
|
|
|
| 3612 |
|
| 3613 |
##### `basic_ostream::operator<<` <a id="ostream.inserters">[[ostream.inserters]]</a>
|
| 3614 |
|
| 3615 |
``` cpp
|
| 3616 |
basic_ostream<charT,traits>& operator<<
|
| 3617 |
+
(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&));
|
| 3618 |
```
|
| 3619 |
|
| 3620 |
*Effects:* None. Does not behave as a formatted output function (as
|
| 3621 |
described in [[ostream.formatted.reqmts]]).
|
| 3622 |
|
| 3623 |
+
*Returns:* `pf(*this)`.[^33]
|
| 3624 |
|
| 3625 |
``` cpp
|
| 3626 |
basic_ostream<charT,traits>& operator<<
|
| 3627 |
+
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
|
| 3628 |
```
|
| 3629 |
|
| 3630 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 3631 |
formatted output function (as described
|
| 3632 |
in [[ostream.formatted.reqmts]]).
|
| 3633 |
|
| 3634 |
+
*Returns:* `*this`.[^34]
|
| 3635 |
|
| 3636 |
``` cpp
|
| 3637 |
basic_ostream<charT,traits>& operator<<
|
| 3638 |
+
(ios_base& (*pf)(ios_base&));
|
| 3639 |
```
|
| 3640 |
|
| 3641 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 3642 |
formatted output function (as described
|
| 3643 |
in [[ostream.formatted.reqmts]]).
|
|
|
|
| 3673 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 3674 |
|
| 3675 |
``` cpp
|
| 3676 |
template<class charT, class traits>
|
| 3677 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 3678 |
+
charT c);
|
| 3679 |
template<class charT, class traits>
|
| 3680 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 3681 |
char c);
|
| 3682 |
// specialization
|
| 3683 |
template<class traits>
|
|
|
|
| 3690 |
template<class traits>
|
| 3691 |
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
|
| 3692 |
unsigned char c);
|
| 3693 |
```
|
| 3694 |
|
| 3695 |
+
*Effects:* Behaves as a formatted output function
|
| 3696 |
+
( [[ostream.formatted.reqmts]]) of `out`. Constructs a character
|
| 3697 |
+
sequence `seq`. If `c` has type `char` and the character type of the
|
| 3698 |
+
stream is not `char`, then `seq` consists of `out.widen(c)`; otherwise
|
| 3699 |
+
`seq` consists of `c`. Determines padding for `seq` as described
|
| 3700 |
+
in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
| 3701 |
+
`os.width(0)`.
|
|
|
|
| 3702 |
|
| 3703 |
*Returns:* `out`.
|
| 3704 |
|
| 3705 |
``` cpp
|
| 3706 |
template<class charT, class traits>
|
|
|
|
| 3721 |
```
|
| 3722 |
|
| 3723 |
*Requires:* `s` shall not be a null pointer.
|
| 3724 |
|
| 3725 |
*Effects:* Behaves like a formatted inserter (as described
|
| 3726 |
+
in [[ostream.formatted.reqmts]]) of `out`. Creates a character sequence
|
| 3727 |
+
`seq` of `n` characters starting at `s`, each widened using
|
| 3728 |
+
`out.widen()` ([[basic.ios.members]]), where `n` is the number that
|
| 3729 |
+
would be computed as if by:
|
| 3730 |
|
| 3731 |
- `traits::length(s)` for the overload where the first argument is of
|
| 3732 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 3733 |
`const charT*`, and also for the overload where the first argument is
|
| 3734 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
|
|
| 3737 |
argument is of type `basic_ostream<charT, traits>&` and the second is
|
| 3738 |
of type `const char*`,
|
| 3739 |
- `traits::length(reinterpret_cast<const char*>(s))` for the other two
|
| 3740 |
overloads.
|
| 3741 |
|
| 3742 |
+
Determines padding for `seq` as described
|
| 3743 |
+
in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
| 3744 |
+
`width(0)`.
|
|
|
|
| 3745 |
|
| 3746 |
*Returns:* `out`.
|
| 3747 |
|
| 3748 |
#### Unformatted output functions <a id="ostream.unformatted">[[ostream.unformatted]]</a>
|
| 3749 |
|
| 3750 |
Each unformatted output function begins execution by constructing an
|
| 3751 |
object of class `sentry`. If this object returns `true`, while
|
| 3752 |
converting to a value of type `bool`, the function endeavors to generate
|
| 3753 |
the requested output. If an exception is thrown during output, then
|
| 3754 |
+
`ios::badbit` is turned on[^35] in `*this`’s error state. If
|
| 3755 |
`(exceptions() & badbit) != 0` then the exception is rethrown. In any
|
| 3756 |
case, the unformatted output function ends by destroying the sentry
|
| 3757 |
object, then, if no exception was thrown, returning the value specified
|
| 3758 |
for the unformatted output function.
|
| 3759 |
|
|
|
|
| 3761 |
basic_ostream<charT,traits>& put(char_type c);
|
| 3762 |
```
|
| 3763 |
|
| 3764 |
*Effects:* Behaves as an unformatted output function (as described
|
| 3765 |
in [[ostream.unformatted]], paragraph 1). After constructing a sentry
|
| 3766 |
+
object, inserts the character `c`, if possible.[^36]
|
| 3767 |
|
| 3768 |
Otherwise, calls `setstate(badbit)` (which may throw
|
| 3769 |
`ios_base::failure` ([[iostate.flags]])).
|
| 3770 |
|
| 3771 |
*Returns:* `*this`.
|
|
|
|
| 3775 |
```
|
| 3776 |
|
| 3777 |
*Effects:* Behaves as an unformatted output function (as described
|
| 3778 |
in [[ostream.unformatted]], paragraph 1). After constructing a sentry
|
| 3779 |
object, obtains characters to insert from successive locations of an
|
| 3780 |
+
array whose first element is designated by `s`.[^37] Characters are
|
| 3781 |
inserted until either of the following occurs:
|
| 3782 |
|
| 3783 |
- `n` characters are inserted;
|
| 3784 |
- inserting in the output sequence fails (in which case the function
|
| 3785 |
calls `setstate(badbit)`, which may throw
|
|
|
|
| 3863 |
*Returns:* An object of unspecified type such that if `out` is an object
|
| 3864 |
of type `basic_ostream<charT, traits>` then the expression
|
| 3865 |
`out << resetiosflags(mask)` behaves as if it called `f(out, mask)`, or
|
| 3866 |
if `in` is an object of type `basic_istream<charT, traits>` then the
|
| 3867 |
expression `in >> resetiosflags(mask)` behaves as if it called
|
| 3868 |
+
`f(in, mask)`, where the function `f` is defined as:[^38]
|
| 3869 |
|
| 3870 |
``` cpp
|
| 3871 |
void f(ios_base& str, ios_base::fmtflags mask) {
|
| 3872 |
// reset specified flags
|
| 3873 |
str.setf(ios_base::fmtflags(0), mask);
|
|
|
|
| 4125 |
str.setstate(ios_base::badbit);
|
| 4126 |
}
|
| 4127 |
```
|
| 4128 |
|
| 4129 |
The expression `out << put_time(tmb, fmt)` shall have type
|
| 4130 |
+
`basic_ostream<charT, traits>&` and value `out`.
|
| 4131 |
+
|
| 4132 |
+
### Quoted manipulators <a id="quoted.manip">[[quoted.manip]]</a>
|
| 4133 |
+
|
| 4134 |
+
Quoted manipulators provide string insertion and extraction of quoted
|
| 4135 |
+
strings (for example, XML and CSV formats). Quoted manipulators are
|
| 4136 |
+
useful in ensuring that the content of a string with embedded spaces
|
| 4137 |
+
remains unchanged if inserted and then extracted via stream I/O.
|
| 4138 |
+
|
| 4139 |
+
``` cpp
|
| 4140 |
+
template <class charT>
|
| 4141 |
+
unspecified quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\'));
|
| 4142 |
+
template <class charT, class traits, class Allocator>
|
| 4143 |
+
unspecified quoted(const basic_string<charT, traits, Allocator>& s,
|
| 4144 |
+
charT delim=charT('"'), charT escape=charT('\\'));
|
| 4145 |
+
```
|
| 4146 |
+
|
| 4147 |
+
*Returns:* An object of unspecified type such that if `out` is an
|
| 4148 |
+
instance of `basic_ostream` with member type `char_type` the same as
|
| 4149 |
+
`charT` and with member type `traits_type`, which in the second form is
|
| 4150 |
+
the same as `traits`, then the expression
|
| 4151 |
+
`out << quoted(s, delim, escape)` behaves as a formatted output
|
| 4152 |
+
function ([[ostream.formatted.reqmts]]) of `out`. This forms a
|
| 4153 |
+
character sequence `seq`, initially consisting of the following
|
| 4154 |
+
elements:
|
| 4155 |
+
|
| 4156 |
+
- `delim`.
|
| 4157 |
+
- Each character in `s`. If the character to be output is equal to
|
| 4158 |
+
`escape` or `delim`, as determined by `traits_type::eq`, first output
|
| 4159 |
+
`escape`.
|
| 4160 |
+
- `delim`.
|
| 4161 |
+
|
| 4162 |
+
Let `x` be the number of elements initially in `seq`. Then padding is
|
| 4163 |
+
determined for `seq` as described in [[ostream.formatted.reqmts]],
|
| 4164 |
+
`seq` is inserted as if by calling `out.rdbuf()->sputn(seq, n)`, where
|
| 4165 |
+
`n` is the larger of `out.width()` and `x`, and `out.width(0)` is
|
| 4166 |
+
called. The expression `out << quoted(s, delim, escape)` shall have type
|
| 4167 |
+
`basic_ostream<charT, traits>&` and value `out`.
|
| 4168 |
+
|
| 4169 |
+
``` cpp
|
| 4170 |
+
template <class charT, class traits, class Allocator>
|
| 4171 |
+
unspecified quoted(basic_string<charT, traits, Allocator>& s,
|
| 4172 |
+
charT delim=charT('"'), charT escape=charT('\\'));
|
| 4173 |
+
```
|
| 4174 |
+
|
| 4175 |
+
*Returns:* An object of unspecified type such that:
|
| 4176 |
+
|
| 4177 |
+
- If `in` is an instance of `basic_istream` with member types
|
| 4178 |
+
`char_type` and `traits_type` the same as `charT` and `traits`,
|
| 4179 |
+
respectively, then the expression `in >> quoted(s, delim, escape)`
|
| 4180 |
+
behaves as if it extracts the following characters from `in` using
|
| 4181 |
+
`basic_istream::operator>>` ([[istream::extractors]]) which may throw
|
| 4182 |
+
`ios_base::failure` ([[ios::failure]]):
|
| 4183 |
+
- If the first character extracted is equal to `delim`, as determined
|
| 4184 |
+
by `traits_type::eq`, then:
|
| 4185 |
+
- Turn off the `skipws` flag.
|
| 4186 |
+
- `s.clear()`
|
| 4187 |
+
- Until an unescaped `delim` character is reached or `!in`, extract
|
| 4188 |
+
characters from `in` and append them to `s`, except that if an
|
| 4189 |
+
`escape` is reached, ignore it and append the next character to
|
| 4190 |
+
`s`.
|
| 4191 |
+
- Discard the final `delim` character.
|
| 4192 |
+
- Restore the `skipws` flag to its original value.
|
| 4193 |
+
- Otherwise, `in >> s`.
|
| 4194 |
+
- If `out` is an instance of `basic_ostream` with member types
|
| 4195 |
+
`char_type` and `traits_type` the same as `charT` and `traits`,
|
| 4196 |
+
respectively, then the expression `out << quoted(s, delim, escape)`
|
| 4197 |
+
behaves as specified for the
|
| 4198 |
+
`const basic_string<charT, traits, Allocator>&` overload of the
|
| 4199 |
+
`quoted` function.
|
| 4200 |
+
|
| 4201 |
+
The expression `in >> quoted(s, delim, escape)` shall have type
|
| 4202 |
+
`basic_istream<charT, traits>&` and value `in`. The expression
|
| 4203 |
+
`out << quoted(s, delim, escape)` shall have type
|
| 4204 |
+
`basic_ostream<charT, traits>&` and value `out`.
|
| 4205 |
|
| 4206 |
## String-based streams <a id="string.streams">[[string.streams]]</a>
|
| 4207 |
|
| 4208 |
### Overview <a id="string.streams.overview">[[string.streams.overview]]</a>
|
| 4209 |
|
|
|
|
| 4288 |
virtual pos_type seekpos(pos_type sp,
|
| 4289 |
ios_base::openmode which
|
| 4290 |
= ios_base::in | ios_base::out);
|
| 4291 |
|
| 4292 |
private:
|
| 4293 |
+
ios_base::openmode mode; // exposition only
|
| 4294 |
};
|
| 4295 |
|
| 4296 |
template <class charT, class traits, class Allocator>
|
| 4297 |
void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
| 4298 |
basic_stringbuf<charT, traits, Allocator>& y);
|
|
|
|
| 4583 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4584 |
|
| 4585 |
basic_string<charT,traits,Allocator> str() const;
|
| 4586 |
void str(const basic_string<charT,traits,Allocator>& s);
|
| 4587 |
private:
|
| 4588 |
+
basic_stringbuf<charT,traits,Allocator> sb; // exposition only
|
| 4589 |
};
|
| 4590 |
|
| 4591 |
template <class charT, class traits, class Allocator>
|
| 4592 |
void swap(basic_istringstream<charT, traits, Allocator>& x,
|
| 4593 |
basic_istringstream<charT, traits, Allocator>& y);
|
|
|
|
| 4713 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4714 |
|
| 4715 |
basic_string<charT,traits,Allocator> str() const;
|
| 4716 |
void str(const basic_string<charT,traits,Allocator>& s);
|
| 4717 |
private:
|
| 4718 |
+
basic_stringbuf<charT,traits,Allocator> sb; // exposition only
|
| 4719 |
};
|
| 4720 |
|
| 4721 |
template <class charT, class traits, class Allocator>
|
| 4722 |
void swap(basic_ostringstream<charT, traits, Allocator>& x,
|
| 4723 |
basic_ostringstream<charT, traits, Allocator>& y);
|
|
|
|
| 4844 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4845 |
basic_string<charT,traits,Allocator> str() const;
|
| 4846 |
void str(const basic_string<charT,traits,Allocator>& str);
|
| 4847 |
|
| 4848 |
private:
|
| 4849 |
+
basic_stringbuf<charT, traits> sb; // exposition only
|
| 4850 |
};
|
| 4851 |
|
| 4852 |
template <class charT, class traits, class Allocator>
|
| 4853 |
void swap(basic_stringstream<charT, traits, Allocator>& x,
|
| 4854 |
basic_stringstream<charT, traits, Allocator>& y);
|
|
|
|
| 4862 |
associated sequence. For the sake of exposition, the maintained data is
|
| 4863 |
presented here as
|
| 4864 |
|
| 4865 |
- `sb`, the `stringbuf` object.
|
| 4866 |
|
| 4867 |
+
#### basic_stringstream constructors <a id="stringstream.cons">[[stringstream.cons]]</a>
|
| 4868 |
|
| 4869 |
``` cpp
|
| 4870 |
explicit basic_stringstream(
|
| 4871 |
ios_base::openmode which = ios_base::out|ios_base::in);
|
| 4872 |
```
|
|
|
|
| 4920 |
basic_stringstream<charT, traits, Allocator>& y);
|
| 4921 |
```
|
| 4922 |
|
| 4923 |
*Effects:* `x.swap(y)`.
|
| 4924 |
|
| 4925 |
+
#### Member functions <a id="stringstream.members">[[stringstream.members]]</a>
|
| 4926 |
|
| 4927 |
``` cpp
|
| 4928 |
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
|
| 4929 |
```
|
| 4930 |
|
|
|
|
| 5159 |
|
| 5160 |
*Effects:* If `is_open() != false`, returns a null pointer. Otherwise,
|
| 5161 |
initializes the `filebuf` as required. It then opens a file, if
|
| 5162 |
possible, whose name is the NTBS`s` (as if by calling
|
| 5163 |
`std::fopen(s,modstr)`). The NTBS`modstr` is determined from
|
| 5164 |
+
`mode & ~ios_base::ate` as indicated in
|
| 5165 |
Table [[tab:iostreams.file.open.modes]]. If `mode` is not some
|
| 5166 |
combination of flags shown in the table then the open fails.
|
| 5167 |
|
| 5168 |
**Table: File open modes** <a id="tab:iostreams.file.open.modes">[tab:iostreams.file.open.modes]</a>
|
| 5169 |
|
|
|
|
| 5188 |
| + | + | | | + | `"a+b"` |
|
| 5189 |
|
| 5190 |
|
| 5191 |
If the open operation succeeds and `(mode & ios_base::ate) != 0`,
|
| 5192 |
positions the file to the end (as if by calling
|
| 5193 |
+
`std::fseek(file,0,SEEK_END)`).[^39]
|
| 5194 |
|
| 5195 |
If the repositioning operation fails, calls `close()` and returns a null
|
| 5196 |
pointer to indicate failure.
|
| 5197 |
|
| 5198 |
*Returns:* `this` if successful, a null pointer otherwise.
|
|
|
|
| 5214 |
`overflow`, `seekoff`, and `seekpos`) was `overflow` then calls
|
| 5215 |
`a_codecvt.unshift` (possibly several times) to determine a termination
|
| 5216 |
sequence, inserts those characters and calls `overflow(traits::eof())`
|
| 5217 |
again. Finally, regardless of whether any of the preceding calls fails
|
| 5218 |
or throws an exception, the function closes the file (as if by calling
|
| 5219 |
+
`std::fclose(file)`).[^40] If any of the calls made by the function,
|
| 5220 |
including `std::fclose`, fails, `close` fails by returning a null
|
| 5221 |
pointer. If one of these calls throws an exception, the exception is
|
| 5222 |
caught and rethrown after closing the file.
|
| 5223 |
|
| 5224 |
*Returns:* `this` on success, a null pointer otherwise.
|
|
|
|
| 5464 |
bool is_open() const;
|
| 5465 |
void open(const char* s, ios_base::openmode mode = ios_base::in);
|
| 5466 |
void open(const string& s, ios_base::openmode mode = ios_base::in);
|
| 5467 |
void close();
|
| 5468 |
private:
|
| 5469 |
+
basic_filebuf<charT,traits> sb; // exposition only
|
| 5470 |
};
|
| 5471 |
|
| 5472 |
template <class charT, class traits>
|
| 5473 |
void swap(basic_ifstream<charT, traits>& x,
|
| 5474 |
basic_ifstream<charT, traits>& y);
|
|
|
|
| 5616 |
bool is_open() const;
|
| 5617 |
void open(const char* s, ios_base::openmode mode = ios_base::out);
|
| 5618 |
void open(const string& s, ios_base::openmode mode = ios_base::out);
|
| 5619 |
void close();
|
| 5620 |
private:
|
| 5621 |
+
basic_filebuf<charT,traits> sb; // exposition only
|
| 5622 |
};
|
| 5623 |
|
| 5624 |
template <class charT, class traits>
|
| 5625 |
void swap(basic_ofstream<charT, traits>& x,
|
| 5626 |
basic_ofstream<charT, traits>& y);
|
|
|
|
| 5772 |
void open(const string& s,
|
| 5773 |
ios_base::openmode mode = ios_base::in|ios_base::out);
|
| 5774 |
void close();
|
| 5775 |
|
| 5776 |
private:
|
| 5777 |
+
basic_filebuf<charT,traits> sb; // exposition only
|
| 5778 |
};
|
| 5779 |
|
| 5780 |
template <class charT, class traits>
|
| 5781 |
void swap(basic_fstream<charT, traits>& x,
|
| 5782 |
basic_fstream<charT, traits>& y);
|
|
|
|
| 5892 |
returns a null pointer, calls `setstate(failbit)` ([[iostate.flags]])
|
| 5893 |
(which may throw `ios_base::failure`).
|
| 5894 |
|
| 5895 |
### C library files <a id="c.files">[[c.files]]</a>
|
| 5896 |
|
| 5897 |
+
Table [[tab:iostreams.hdr.cstdio]] describes header `<cstdio>`. C++does
|
| 5898 |
+
not define the function `gets`.
|
| 5899 |
|
| 5900 |
Calls to the function `tmpnam` with an argument of `NULL` may introduce
|
| 5901 |
a data race ([[res.on.data.races]]) with other calls to `tmpnam` with
|
| 5902 |
an argument of `NULL`.
|
| 5903 |
|
|
|
|
| 5934 |
[bitmask.types]: library.md#bitmask.types
|
| 5935 |
[c.files]: #c.files
|
| 5936 |
[enumerated.types]: library.md#enumerated.types
|
| 5937 |
[error.reporting]: #error.reporting
|
| 5938 |
[ext.manip]: #ext.manip
|
|
|
|
| 5939 |
[fig:streampos]: #fig:streampos
|
| 5940 |
[file.streams]: #file.streams
|
| 5941 |
[filebuf]: #filebuf
|
| 5942 |
[filebuf.assign]: #filebuf.assign
|
| 5943 |
[filebuf.cons]: #filebuf.cons
|
|
|
|
| 6032 |
[ostringstream]: #ostringstream
|
| 6033 |
[ostringstream.assign]: #ostringstream.assign
|
| 6034 |
[ostringstream.cons]: #ostringstream.cons
|
| 6035 |
[ostringstream.members]: #ostringstream.members
|
| 6036 |
[output.streams]: #output.streams
|
| 6037 |
+
[quoted.manip]: #quoted.manip
|
| 6038 |
[res.on.data.races]: library.md#res.on.data.races
|
| 6039 |
[res.on.exception.handling]: library.md#res.on.exception.handling
|
| 6040 |
[std.ios.manip]: #std.ios.manip
|
| 6041 |
[std.manip]: #std.manip
|
| 6042 |
[stream.buffers]: #stream.buffers
|
|
|
|
| 6146 |
|
| 6147 |
[^15]: Classes derived from `basic_streambuf` can provide more efficient
|
| 6148 |
ways to implement `xsgetn()` and `xsputn()` by overriding these
|
| 6149 |
definitions from the base class.
|
| 6150 |
|
| 6151 |
+
[^16]: Typically, `overflow` returns `c` to indicate success, except
|
| 6152 |
+
when `traits::eq_int_type(c,traits::eof())` returns `true`, in which
|
| 6153 |
+
case it returns `traits::not_eof(c)`.
|
| 6154 |
+
|
| 6155 |
+
[^17]: This will be possible only in functions that are part of the
|
| 6156 |
library. The semantics of the constructor used in user code is as
|
| 6157 |
specified.
|
| 6158 |
|
| 6159 |
+
[^18]: The sentry constructor and destructor can also perform additional
|
| 6160 |
implementation-dependent operations.
|
| 6161 |
|
| 6162 |
+
[^19]: This is done without causing an `ios::failure` to be thrown.
|
|
|
|
|
|
|
|
|
|
| 6163 |
|
| 6164 |
[^20]: See, for example, the function signature
|
| 6165 |
+
`ws(basic_istream&)` ([[istream.manip]]).
|
| 6166 |
+
|
| 6167 |
+
[^21]: See, for example, the function signature
|
| 6168 |
`dec(ios_base&)` ([[basefield.manip]]).
|
| 6169 |
|
| 6170 |
+
[^22]: This is done without causing an `ios::failure` to be thrown.
|
|
|
|
|
|
|
|
|
|
| 6171 |
|
| 6172 |
[^23]: Note that this function is not overloaded on types `signed char`
|
| 6173 |
and `unsigned char`.
|
| 6174 |
|
| 6175 |
[^24]: Note that this function is not overloaded on types `signed char`
|
| 6176 |
and `unsigned char`.
|
| 6177 |
|
| 6178 |
+
[^25]: Note that this function is not overloaded on types `signed char`
|
| 6179 |
+
and `unsigned char`.
|
| 6180 |
+
|
| 6181 |
+
[^26]: Since the final input character is “extracted,” it is counted in
|
| 6182 |
the `gcount()`, even though it is not stored.
|
| 6183 |
|
| 6184 |
+
[^27]: This allows an input line which exactly fills the buffer, without
|
| 6185 |
setting `failbit`. This is different behavior than the historical
|
| 6186 |
AT&T implementation.
|
| 6187 |
|
| 6188 |
+
[^28]: This implies an empty input line will not cause `failbit` to be
|
| 6189 |
set.
|
| 6190 |
|
| 6191 |
+
[^29]: Note that this function is not overloaded on types `signed char`
|
| 6192 |
and `unsigned char`.
|
| 6193 |
|
| 6194 |
+
[^30]: The call `os.tie()->flush()` does not necessarily occur if the
|
| 6195 |
function can determine that no synchronization is necessary.
|
| 6196 |
|
| 6197 |
+
[^31]: The `sentry` constructor and destructor can also perform
|
| 6198 |
additional implementation-dependent operations.
|
| 6199 |
|
| 6200 |
+
[^32]: without causing an `ios::failure` to be thrown.
|
|
|
|
|
|
|
|
|
|
| 6201 |
|
| 6202 |
[^33]: See, for example, the function signature
|
| 6203 |
+
`endl(basic_ostream&)` ([[ostream.manip]]).
|
| 6204 |
+
|
| 6205 |
+
[^34]: See, for example, the function signature
|
| 6206 |
`dec(ios_base&)` ([[basefield.manip]]).
|
| 6207 |
|
| 6208 |
+
[^35]: without causing an `ios::failure` to be thrown.
|
|
|
|
|
|
|
|
|
|
| 6209 |
|
| 6210 |
[^36]: Note that this function is not overloaded on types `signed char`
|
| 6211 |
and `unsigned char`.
|
| 6212 |
|
| 6213 |
+
[^37]: Note that this function is not overloaded on types `signed char`
|
| 6214 |
+
and `unsigned char`.
|
| 6215 |
+
|
| 6216 |
+
[^38]: The expression `cin >>resetiosflags(ios_base::skipws)` clears
|
| 6217 |
`ios_base::skipws` in the format flags stored in the
|
| 6218 |
`basic_istream<charT,traits>` object `cin` (the same as
|
| 6219 |
`cin >>noskipws`), and the expression
|
| 6220 |
`cout << resetiosflags(ios_base::showbase)` clears
|
| 6221 |
`ios_base::showbase` in the format flags stored in the
|
| 6222 |
`basic_ostream<charT,traits>` object `cout` (the same as
|
| 6223 |
`cout <<noshowbase`).
|
| 6224 |
|
| 6225 |
+
[^39]: The macro `SEEK_END` is defined, and the function signatures
|
| 6226 |
`fopen(const char*, const char*)` and `fseek(FILE*, long, int)` are
|
| 6227 |
declared, in `<cstdio>` ([[c.files]]).
|
| 6228 |
|
| 6229 |
+
[^40]: The function signature `fclose(FILE*)` is declared in `<cstdio>`
|
| 6230 |
([[c.files]]).
|