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

33 lines
2.4 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.overview]
# 31 Input/output library [[input.output]](./#input.output)
## 31.11 Synchronized output streams [[syncstream]](syncstream#syncbuf.overview)
### 31.11.2 Class template basic_syncbuf [[syncstream.syncbuf]](syncstream.syncbuf#overview)
#### 31.11.2.1 Overview [syncstream.syncbuf.overview]
[🔗](#lib:basic_syncbuf)
namespace std {template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>class basic_syncbuf : public basic_streambuf<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; using allocator_type = Allocator; using streambuf_type = basic_streambuf<charT, traits>; // [[syncstream.syncbuf.cons]](syncstream.syncbuf.cons "31.11.2.2Construction and destruction"), construction and destruction basic_syncbuf(): basic_syncbuf(nullptr) {}explicit basic_syncbuf(streambuf_type* obuf): basic_syncbuf(obuf, Allocator()) {} basic_syncbuf(streambuf_type*, const Allocator&);
basic_syncbuf(basic_syncbuf&&); ~basic_syncbuf(); // [[syncstream.syncbuf.assign]](syncstream.syncbuf.assign "31.11.2.3Assignment and swap"), assignment and swap basic_syncbuf& operator=(basic_syncbuf&&); void swap(basic_syncbuf&); // [[syncstream.syncbuf.members]](syncstream.syncbuf.members "31.11.2.4Member functions"), member functionsbool emit();
streambuf_type* get_wrapped() const noexcept;
allocator_type get_allocator() const noexcept; void set_emit_on_sync(bool) noexcept; protected:// [[syncstream.syncbuf.virtuals]](syncstream.syncbuf.virtuals "31.11.2.5Overridden virtual functions"), overridden virtual functionsint sync() override; private: streambuf_type* *wrapped*; // *exposition only*bool *emit-on-sync*{}; // *exposition only*};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12649)
Class template basic_syncbuf stores character data
written to it, known as the associated output, into internal
buffers allocated using the object's allocator[.](#1.sentence-1)
The associated output is transferred to the
wrapped stream buffer object **wrapped* when emit() is called
or when the basic_syncbuf object is destroyed[.](#1.sentence-2)
Such transfers are atomic with respect to transfers
by other basic_syncbuf objects
with the same wrapped stream buffer object[.](#1.sentence-3)