tmp/tmp7tsc1r31/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Member functions <a id="syncstream.osyncstream.members">[[syncstream.osyncstream.members]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
void emit();
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
*Effects:* Calls `sb.emit()`. If that call returns `false`, calls
|
| 8 |
+
`setstate(ios_base::badbit)`.
|
| 9 |
+
|
| 10 |
+
[*Example 1*:
|
| 11 |
+
|
| 12 |
+
A flush on a `basic_osyncstream` does not flush immediately:
|
| 13 |
+
|
| 14 |
+
``` cpp
|
| 15 |
+
{
|
| 16 |
+
osyncstream bout(cout);
|
| 17 |
+
bout << "Hello," << '\n'; // no flush
|
| 18 |
+
bout.emit(); // characters transferred; cout not flushed
|
| 19 |
+
bout << "World!" << endl; // flush noted; cout not flushed
|
| 20 |
+
bout.emit(); // characters transferred; cout flushed
|
| 21 |
+
bout << "Greetings." << '\n'; // no flush
|
| 22 |
+
} // characters transferred; cout not flushed
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
— *end example*]
|
| 26 |
+
|
| 27 |
+
[*Example 2*:
|
| 28 |
+
|
| 29 |
+
The function `emit()` can be used to handle exceptions from operations
|
| 30 |
+
on the underlying stream.
|
| 31 |
+
|
| 32 |
+
``` cpp
|
| 33 |
+
{
|
| 34 |
+
osyncstream bout(cout);
|
| 35 |
+
bout << "Hello, " << "World!" << '\n';
|
| 36 |
+
try {
|
| 37 |
+
bout.emit();
|
| 38 |
+
} catch (...) {
|
| 39 |
+
// handle exception
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
— *end example*]
|
| 45 |
+
|
| 46 |
+
``` cpp
|
| 47 |
+
streambuf_type* get_wrapped() const noexcept;
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
*Returns:* `sb.get_wrapped()`.
|
| 51 |
+
|
| 52 |
+
[*Example 3*:
|
| 53 |
+
|
| 54 |
+
Obtaining the wrapped stream buffer with `get_wrapped()` allows wrapping
|
| 55 |
+
it again with an `osyncstream`. For example,
|
| 56 |
+
|
| 57 |
+
``` cpp
|
| 58 |
+
{
|
| 59 |
+
osyncstream bout1(cout);
|
| 60 |
+
bout1 << "Hello, ";
|
| 61 |
+
{
|
| 62 |
+
osyncstream(bout1.get_wrapped()) << "Goodbye, " << "Planet!" << '\n';
|
| 63 |
+
}
|
| 64 |
+
bout1 << "World!" << '\n';
|
| 65 |
+
}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
produces the *uninterleaved* output
|
| 69 |
+
|
| 70 |
+
``` text
|
| 71 |
+
Goodbye, Planet!
|
| 72 |
+
Hello, World!
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
— *end example*]
|
| 76 |
+
|