From Jason Turner

[syncstream.osyncstream.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo4kco9d_/{from.md → to.md} +73 -0
tmp/tmpo4kco9d_/{from.md → to.md} RENAMED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Overview <a id="syncstream.osyncstream.overview">[[syncstream.osyncstream.overview]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
6
+ class basic_osyncstream : public basic_ostream<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
+
14
+ using allocator_type = Allocator;
15
+ using streambuf_type = basic_streambuf<charT, traits>;
16
+ using syncbuf_type = basic_syncbuf<charT, traits, Allocator>;
17
+
18
+ // [syncstream.osyncstream.cons], construction and destruction
19
+ basic_osyncstream(streambuf_type*, const Allocator&);
20
+ explicit basic_osyncstream(streambuf_type* obuf)
21
+ : basic_osyncstream(obuf, Allocator()) {}
22
+ basic_osyncstream(basic_ostream<charT, traits>& os, const Allocator& allocator)
23
+ : basic_osyncstream(os.rdbuf(), allocator) {}
24
+ explicit basic_osyncstream(basic_ostream<charT, traits>& os)
25
+ : basic_osyncstream(os, Allocator()) {}
26
+ basic_osyncstream(basic_osyncstream&&) noexcept;
27
+ ~basic_osyncstream();
28
+
29
+ // assignment
30
+ basic_osyncstream& operator=(basic_osyncstream&&) noexcept;
31
+
32
+ // [syncstream.osyncstream.members], member functions
33
+ void emit();
34
+ streambuf_type* get_wrapped() const noexcept;
35
+ syncbuf_type* rdbuf() const noexcept { return const_cast<syncbuf_type*>(addressof(sb)); }
36
+
37
+ private:
38
+ syncbuf_type sb; // exposition only
39
+ };
40
+ }
41
+ ```
42
+
43
+ `Allocator` shall meet the *Cpp17Allocator* requirements (
44
+ [[cpp17.allocator]]).
45
+
46
+ [*Example 1*:
47
+
48
+ A named variable can be used within a block statement for streaming.
49
+
50
+ ``` cpp
51
+ {
52
+ osyncstream bout(cout);
53
+ bout << "Hello, ";
54
+ bout << "World!";
55
+ bout << endl; // flush is noted
56
+ bout << "and more!\n";
57
+ } // characters are transferred and cout is flushed
58
+ ```
59
+
60
+ — *end example*]
61
+
62
+ [*Example 2*:
63
+
64
+ A temporary object can be used for streaming within a single statement.
65
+
66
+ ``` cpp
67
+ osyncstream(cout) << "Hello, " << "World!" << '\n';
68
+ ```
69
+
70
+ In this example, `cout` is not flushed.
71
+
72
+ — *end example*]
73
+