tmp/tmpa2gr3f4v/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Overview <a id="syncstream.syncbuf.overview">[[syncstream.syncbuf.overview]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
|
| 6 |
+
class basic_syncbuf : public basic_streambuf<charT, traits> {
|
| 7 |
+
public:
|
| 8 |
+
using char_type = charT;
|
| 9 |
+
using int_type = typename traits::int_type;
|
| 10 |
+
using pos_type = typename traits::pos_type;
|
| 11 |
+
using off_type = typename traits::off_type;
|
| 12 |
+
using traits_type = traits;
|
| 13 |
+
using allocator_type = Allocator;
|
| 14 |
+
|
| 15 |
+
using streambuf_type = basic_streambuf<charT, traits>;
|
| 16 |
+
|
| 17 |
+
// [syncstream.syncbuf.cons], construction and destruction
|
| 18 |
+
basic_syncbuf()
|
| 19 |
+
: basic_syncbuf(nullptr) {}
|
| 20 |
+
explicit basic_syncbuf(streambuf_type* obuf)
|
| 21 |
+
: basic_syncbuf(obuf, Allocator()) {}
|
| 22 |
+
basic_syncbuf(streambuf_type*, const Allocator&);
|
| 23 |
+
basic_syncbuf(basic_syncbuf&&);
|
| 24 |
+
~basic_syncbuf();
|
| 25 |
+
|
| 26 |
+
// [syncstream.syncbuf.assign], assignment and swap
|
| 27 |
+
basic_syncbuf& operator=(basic_syncbuf&&);
|
| 28 |
+
void swap(basic_syncbuf&);
|
| 29 |
+
|
| 30 |
+
// [syncstream.syncbuf.members], member functions
|
| 31 |
+
bool emit();
|
| 32 |
+
streambuf_type* get_wrapped() const noexcept;
|
| 33 |
+
allocator_type get_allocator() const noexcept;
|
| 34 |
+
void set_emit_on_sync(bool) noexcept;
|
| 35 |
+
|
| 36 |
+
protected:
|
| 37 |
+
// [syncstream.syncbuf.virtuals], overridden virtual functions
|
| 38 |
+
int sync() override;
|
| 39 |
+
|
| 40 |
+
private:
|
| 41 |
+
streambuf_type* wrapped; // exposition only
|
| 42 |
+
bool emit_on_sync{}; // exposition only
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
// [syncstream.syncbuf.special], specialized algorithms
|
| 46 |
+
template<class charT, class traits, class Allocator>
|
| 47 |
+
void swap(basic_syncbuf<charT, traits, Allocator>&,
|
| 48 |
+
basic_syncbuf<charT, traits, Allocator>&);
|
| 49 |
+
}
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
Class template `basic_syncbuf` stores character data written to it,
|
| 53 |
+
known as the associated output, into internal buffers allocated using
|
| 54 |
+
the object’s allocator. The associated output is transferred to the
|
| 55 |
+
wrapped stream buffer object `*wrapped` when `emit()` is called or when
|
| 56 |
+
the `basic_syncbuf` object is destroyed. Such transfers are atomic with
|
| 57 |
+
respect to transfers by other `basic_syncbuf` objects with the same
|
| 58 |
+
wrapped stream buffer object.
|
| 59 |
+
|