31 Input/output library [input.output]

31.11 Synchronized output streams [syncstream]

31.11.3 Class template basic_osyncstream [syncstream.osyncstream]

31.11.3.3 Member functions [syncstream.osyncstream.members]

void emit();
Effects: Behaves as an unformatted output function ([ostream.unformatted]).
After constructing a sentry object, calls sb.emit().
If that call returns false, calls setstate(ios_base​::​badbit).
[Example 1: 
A flush on a basic_osyncstream does not flush immediately: { osyncstream bout(cout); bout << "Hello," << '\n'; // no flush bout.emit(); // characters transferred; cout not flushed bout << "World!" << endl; // flush noted; cout not flushed bout.emit(); // characters transferred; cout flushed bout << "Greetings." << '\n'; // no flush } // characters transferred; cout not flushed
— end example]
[Example 2: 
The function emit() can be used to handle exceptions from operations on the underlying stream.
{ osyncstream bout(cout); bout << "Hello, " << "World!" << '\n'; try { bout.emit(); } catch (...) { // handle exception } } — end example]
streambuf_type* get_wrapped() const noexcept;
Returns: sb.get_wrapped().
[Example 3: 
Obtaining the wrapped stream buffer with get_wrapped() allows wrapping it again with an osyncstream.
For example, { osyncstream bout1(cout); bout1 << "Hello, "; { osyncstream(bout1.get_wrapped()) << "Goodbye, " << "Planet!" << '\n'; } bout1 << "World!" << '\n'; } produces the uninterleaved output
Goodbye, Planet!
Hello, World!
— end example]