Files
cppdraft_translate/cppdraft/syncstream/syncbuf/members.md
2025-10-25 03:02:53 +03:00

102 lines
3.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.2Data 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)