tmp/tmpwedon4m7/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### Class `basic_ostream::sentry` <a id="ostream.sentry">[[ostream.sentry]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class charT, class traits = char_traits<charT>>
|
| 6 |
+
class basic_ostream<charT, traits>::sentry {
|
| 7 |
+
bool ok_; // exposition only
|
| 8 |
+
public:
|
| 9 |
+
explicit sentry(basic_ostream<charT, traits>& os);
|
| 10 |
+
~sentry();
|
| 11 |
+
explicit operator bool() const { return ok_; }
|
| 12 |
+
|
| 13 |
+
sentry(const sentry&) = delete;
|
| 14 |
+
sentry& operator=(const sentry&) = delete;
|
| 15 |
+
};
|
| 16 |
+
}
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
The class `sentry` defines a class that is responsible for doing
|
| 20 |
+
exception safe prefix and suffix operations.
|
| 21 |
+
|
| 22 |
+
``` cpp
|
| 23 |
+
explicit sentry(basic_ostream<charT, traits>& os);
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
If `os.good()` is nonzero, prepares for formatted or unformatted output.
|
| 27 |
+
If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^31]
|
| 28 |
+
|
| 29 |
+
If, after any preparation is completed, `os.good()` is `true`,
|
| 30 |
+
`ok_ == true` otherwise, `ok_ == false`. During preparation, the
|
| 31 |
+
constructor may call `setstate(failbit)` (which may throw
|
| 32 |
+
`ios_base::failure` [[iostate.flags]]).[^32]
|
| 33 |
+
|
| 34 |
+
``` cpp
|
| 35 |
+
~sentry();
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
If
|
| 39 |
+
`(os.flags() & ios_base::unitbuf) && !uncaught_exceptions() && os.good()`
|
| 40 |
+
is `true`, calls `os.rdbuf()->pubsync()`. If that function returns -1,
|
| 41 |
+
sets `badbit` in `os.rdstate()` without propagating an exception.
|
| 42 |
+
|
| 43 |
+
``` cpp
|
| 44 |
+
explicit operator bool() const;
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
*Effects:* Returns `ok_`.
|
| 48 |
+
|