[syncstream.syncbuf.members]

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

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

### 31.11.2 Class template basic_syncbuf [[syncstream.syncbuf]](syncstream.syncbuf#members)

#### 31.11.2.4 Member functions [syncstream.syncbuf.members]

[ð](#lib:emit,basic_syncbuf)

`bool emit();
`

[1](#1)

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

*Effects*: Atomically transfers the associated output of *this to the stream buffer **wrapped*,
so that it appears in the output stream
as a contiguous sequence of characters[.](#1.sentence-1)

*wrapped*->pubsync() is called
if and only if a call was made to sync() since the most recent call to emit(), if any[.](#1.sentence-2)

[2](#2)

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

*Synchronization*: All emit() calls transferring characters
to the same stream buffer object
appear to execute in a total order
consistent with the âhappens beforeâ relation ([[intro.races]](intro.races "6.10.2.2 Data races")),
where each emit() call
synchronizes with
subsequent emit() calls in that total order[.](#2.sentence-1)

[3](#3)

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

*Postconditions*: On success, the associated output is empty[.](#3.sentence-1)

[4](#4)

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

*Returns*: true if all of the following conditions hold;
otherwise false:

- [(4.1)](#4.1)

  *wrapped* == nullptr is false[.](#4.1.sentence-1)

- [(4.2)](#4.2)

  All of the characters in the associated output were successfully transferred[.](#4.2.sentence-1)

- [(4.3)](#4.3)

  The call to *wrapped*->pubsync() (if any) succeeded[.](#4.3.sentence-1)

[5](#5)

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

*Remarks*: May call member functions of *wrapped* while holding a lock uniquely associated with *wrapped*[.](#5.sentence-1)

[ð](#lib:get_wrapped,basic_syncbuf)

`streambuf_type* get_wrapped() const noexcept;
`

[6](#6)

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

*Returns*: *wrapped*[.](#6.sentence-1)

[ð](#lib:get_allocator,basic_syncbuf)

`allocator_type get_allocator() const noexcept;
`

[7](#7)

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

*Returns*: A copy of the allocator that was set in the constructor or assignment operator[.](#7.sentence-1)

[ð](#lib:set_emit_on_sync,basic_syncbuf)

`void set_emit_on_sync(bool b) noexcept;
`

[8](#8)

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

*Effects*: *emit-on-sync* = b[.](#8.sentence-1)
