tmp/tmpi26wdj61/{from.md → to.md}
RENAMED
|
@@ -6,19 +6,28 @@ Each formatted output function begins execution by constructing an
|
|
| 6 |
object of class `sentry`. If this object returns `true` when converted
|
| 7 |
to a value of type `bool`, the function endeavors to generate the
|
| 8 |
requested output. If the generation fails, then the formatted output
|
| 9 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 10 |
exception. If an exception is thrown during output, then `ios::badbit`
|
| 11 |
-
is turned on[^
|
| 12 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 13 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 14 |
leaving the formatted output function. If no exception is thrown, the
|
| 15 |
result of the formatted output function is `*this`.
|
| 16 |
|
| 17 |
-
The descriptions of the individual formatted output
|
| 18 |
how they perform output and do not mention the `sentry` object.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
|
| 21 |
|
| 22 |
``` cpp
|
| 23 |
operator<<(bool val);
|
| 24 |
operator<<(short val);
|
|
@@ -90,11 +99,11 @@ performed the following code fragment:
|
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
bool failed = use_facet<
|
| 93 |
num_put<charT,ostreambuf_iterator<charT,traits> >
|
| 94 |
>(getloc()).put(*this, *this, fill(),
|
| 95 |
-
static_cast<double>(
|
| 96 |
```
|
| 97 |
|
| 98 |
The first argument provides an object of the `ostreambuf_iterator<>`
|
| 99 |
class which is an iterator for class `basic_ostream<>`. It bypasses
|
| 100 |
`ostream`s and uses `streambuf`s directly. Class `locale` relies on
|
|
@@ -109,32 +118,32 @@ from which to obtain other facets. If `failed` is `true` then does
|
|
| 109 |
|
| 110 |
##### `basic_ostream::operator<<` <a id="ostream.inserters">[[ostream.inserters]]</a>
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
basic_ostream<charT,traits>& operator<<
|
| 114 |
-
(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
|
| 115 |
```
|
| 116 |
|
| 117 |
*Effects:* None. Does not behave as a formatted output function (as
|
| 118 |
described in [[ostream.formatted.reqmts]]).
|
| 119 |
|
| 120 |
-
*Returns:* `pf(*this)`.[^
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
basic_ostream<charT,traits>& operator<<
|
| 124 |
-
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&))
|
| 125 |
```
|
| 126 |
|
| 127 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 128 |
formatted output function (as described
|
| 129 |
in [[ostream.formatted.reqmts]]).
|
| 130 |
|
| 131 |
-
*Returns:* `*this`.[^
|
| 132 |
|
| 133 |
``` cpp
|
| 134 |
basic_ostream<charT,traits>& operator<<
|
| 135 |
-
(ios_base& (*pf)(ios_base&))
|
| 136 |
```
|
| 137 |
|
| 138 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 139 |
formatted output function (as described
|
| 140 |
in [[ostream.formatted.reqmts]]).
|
|
@@ -170,11 +179,11 @@ caught exception is rethrown.
|
|
| 170 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 171 |
|
| 172 |
``` cpp
|
| 173 |
template<class charT, class traits>
|
| 174 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 175 |
-
charT c
|
| 176 |
template<class charT, class traits>
|
| 177 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 178 |
char c);
|
| 179 |
// specialization
|
| 180 |
template<class traits>
|
|
@@ -187,18 +196,17 @@ template<class traits>
|
|
| 187 |
template<class traits>
|
| 188 |
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
|
| 189 |
unsigned char c);
|
| 190 |
```
|
| 191 |
|
| 192 |
-
*Effects:* Behaves
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
into `out`.
|
| 200 |
|
| 201 |
*Returns:* `out`.
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
template<class charT, class traits>
|
|
@@ -219,13 +227,14 @@ template<class traits>
|
|
| 219 |
```
|
| 220 |
|
| 221 |
*Requires:* `s` shall not be a null pointer.
|
| 222 |
|
| 223 |
*Effects:* Behaves like a formatted inserter (as described
|
| 224 |
-
in [[ostream.formatted.reqmts]]) of `out`.
|
| 225 |
-
|
| 226 |
-
|
|
|
|
| 227 |
|
| 228 |
- `traits::length(s)` for the overload where the first argument is of
|
| 229 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 230 |
`const charT*`, and also for the overload where the first argument is
|
| 231 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
@@ -234,12 +243,11 @@ number that would be computed as if by:
|
|
| 234 |
argument is of type `basic_ostream<charT, traits>&` and the second is
|
| 235 |
of type `const char*`,
|
| 236 |
- `traits::length(reinterpret_cast<const char*>(s))` for the other two
|
| 237 |
overloads.
|
| 238 |
|
| 239 |
-
|
| 240 |
-
`
|
| 241 |
-
`
|
| 242 |
-
required padding are inserted into `out`. Calls `width(0)`.
|
| 243 |
|
| 244 |
*Returns:* `out`.
|
| 245 |
|
|
|
|
| 6 |
object of class `sentry`. If this object returns `true` when converted
|
| 7 |
to a value of type `bool`, the function endeavors to generate the
|
| 8 |
requested output. If the generation fails, then the formatted output
|
| 9 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 10 |
exception. If an exception is thrown during output, then `ios::badbit`
|
| 11 |
+
is turned on[^32] in `*this`’s error state. If
|
| 12 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 13 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 14 |
leaving the formatted output function. If no exception is thrown, the
|
| 15 |
result of the formatted output function is `*this`.
|
| 16 |
|
| 17 |
+
The descriptions of the individual formatted output functions describe
|
| 18 |
how they perform output and do not mention the `sentry` object.
|
| 19 |
|
| 20 |
+
If a formatted output function of a stream `os` determines padding, it
|
| 21 |
+
does so as follows. Given a `charT` character sequence `seq` where
|
| 22 |
+
`charT` is the character type of the stream, if the length of `seq` is
|
| 23 |
+
less than `os.width()`, then enough copies of `os.fill()` are added to
|
| 24 |
+
this sequence as necessary to pad to a width of `os.width()` characters.
|
| 25 |
+
If `(os.flags() & ios_base::adjustfield) == ios_base::left` is `true`,
|
| 26 |
+
the fill characters are placed after the character sequence; otherwise,
|
| 27 |
+
they are placed before the character sequence.
|
| 28 |
+
|
| 29 |
##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
operator<<(bool val);
|
| 33 |
operator<<(short val);
|
|
|
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
bool failed = use_facet<
|
| 102 |
num_put<charT,ostreambuf_iterator<charT,traits> >
|
| 103 |
>(getloc()).put(*this, *this, fill(),
|
| 104 |
+
static_cast<double>(val)).failed();
|
| 105 |
```
|
| 106 |
|
| 107 |
The first argument provides an object of the `ostreambuf_iterator<>`
|
| 108 |
class which is an iterator for class `basic_ostream<>`. It bypasses
|
| 109 |
`ostream`s and uses `streambuf`s directly. Class `locale` relies on
|
|
|
|
| 118 |
|
| 119 |
##### `basic_ostream::operator<<` <a id="ostream.inserters">[[ostream.inserters]]</a>
|
| 120 |
|
| 121 |
``` cpp
|
| 122 |
basic_ostream<charT,traits>& operator<<
|
| 123 |
+
(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&));
|
| 124 |
```
|
| 125 |
|
| 126 |
*Effects:* None. Does not behave as a formatted output function (as
|
| 127 |
described in [[ostream.formatted.reqmts]]).
|
| 128 |
|
| 129 |
+
*Returns:* `pf(*this)`.[^33]
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
basic_ostream<charT,traits>& operator<<
|
| 133 |
+
(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
|
| 134 |
```
|
| 135 |
|
| 136 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 137 |
formatted output function (as described
|
| 138 |
in [[ostream.formatted.reqmts]]).
|
| 139 |
|
| 140 |
+
*Returns:* `*this`.[^34]
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
basic_ostream<charT,traits>& operator<<
|
| 144 |
+
(ios_base& (*pf)(ios_base&));
|
| 145 |
```
|
| 146 |
|
| 147 |
*Effects:* Calls `pf(*this)`. This inserter does not behave as a
|
| 148 |
formatted output function (as described
|
| 149 |
in [[ostream.formatted.reqmts]]).
|
|
|
|
| 179 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
template<class charT, class traits>
|
| 183 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 184 |
+
charT c);
|
| 185 |
template<class charT, class traits>
|
| 186 |
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
|
| 187 |
char c);
|
| 188 |
// specialization
|
| 189 |
template<class traits>
|
|
|
|
| 196 |
template<class traits>
|
| 197 |
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
|
| 198 |
unsigned char c);
|
| 199 |
```
|
| 200 |
|
| 201 |
+
*Effects:* Behaves as a formatted output function
|
| 202 |
+
( [[ostream.formatted.reqmts]]) of `out`. Constructs a character
|
| 203 |
+
sequence `seq`. If `c` has type `char` and the character type of the
|
| 204 |
+
stream is not `char`, then `seq` consists of `out.widen(c)`; otherwise
|
| 205 |
+
`seq` consists of `c`. Determines padding for `seq` as described
|
| 206 |
+
in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
| 207 |
+
`os.width(0)`.
|
|
|
|
| 208 |
|
| 209 |
*Returns:* `out`.
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
template<class charT, class traits>
|
|
|
|
| 227 |
```
|
| 228 |
|
| 229 |
*Requires:* `s` shall not be a null pointer.
|
| 230 |
|
| 231 |
*Effects:* Behaves like a formatted inserter (as described
|
| 232 |
+
in [[ostream.formatted.reqmts]]) of `out`. Creates a character sequence
|
| 233 |
+
`seq` of `n` characters starting at `s`, each widened using
|
| 234 |
+
`out.widen()` ([[basic.ios.members]]), where `n` is the number that
|
| 235 |
+
would be computed as if by:
|
| 236 |
|
| 237 |
- `traits::length(s)` for the overload where the first argument is of
|
| 238 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 239 |
`const charT*`, and also for the overload where the first argument is
|
| 240 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
|
|
| 243 |
argument is of type `basic_ostream<charT, traits>&` and the second is
|
| 244 |
of type `const char*`,
|
| 245 |
- `traits::length(reinterpret_cast<const char*>(s))` for the other two
|
| 246 |
overloads.
|
| 247 |
|
| 248 |
+
Determines padding for `seq` as described
|
| 249 |
+
in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
| 250 |
+
`width(0)`.
|
|
|
|
| 251 |
|
| 252 |
*Returns:* `out`.
|
| 253 |
|