[syncstream.osyncstream.members]

# 31 Input/output library [[input.output]](./#input.output)

## 31.11 Synchronized output streams [[syncstream]](syncstream#osyncstream.members)

### 31.11.3 Class template basic_osyncstream [[syncstream.osyncstream]](syncstream.osyncstream#members)

#### 31.11.3.3 Member functions [syncstream.osyncstream.members]

[ð](#lib:set_emit_on_sync,basic_osyncstream)

`void emit();
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L13038)

*Effects*: Behaves as an unformatted output function ([[ostream.unformatted]](ostream.unformatted "31.7.6.4 Unformatted output functions"))[.](#1.sentence-1)

After constructing a sentry object, calls *sb*.emit()[.](#1.sentence-2)

If that call returns false,
calls setstate(ios_base​::​badbit)[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L13045)

[*Example [1](#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*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L13060)

[*Example [2](#example-2)*:

The function emit() can be used to
handle exceptions from operations on the underlying stream[.](#3.sentence-1)

{ osyncstream bout(cout);
 bout << "Hello, " << "World!" << '\n'; try { bout.emit(); } catch (...) {// handle exception}} â *end example*]

[ð](#lib:set_emit_on_sync,basic_osyncstream_)

`streambuf_type* get_wrapped() const noexcept;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L13084)

*Returns*: *sb*.get_wrapped()[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L13088)

[*Example [3](#example-3)*:

Obtaining the wrapped stream buffer with get_wrapped() allows wrapping it again with an osyncstream[.](#5.sentence-1)

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*]
