tmp/tmp0n9_44pd/{from.md → to.md}
RENAMED
|
@@ -41,15 +41,10 @@ namespace std {
|
|
| 41 |
|
| 42 |
private:
|
| 43 |
streambuf_type* wrapped; // exposition only
|
| 44 |
bool emit_on_sync{}; // exposition only
|
| 45 |
};
|
| 46 |
-
|
| 47 |
-
// [syncstream.syncbuf.special], specialized algorithms
|
| 48 |
-
template<class charT, class traits, class Allocator>
|
| 49 |
-
void swap(basic_syncbuf<charT, traits, Allocator>&,
|
| 50 |
-
basic_syncbuf<charT, traits, Allocator>&);
|
| 51 |
}
|
| 52 |
```
|
| 53 |
|
| 54 |
Class template `basic_syncbuf` stores character data written to it,
|
| 55 |
known as the associated output, into internal buffers allocated using
|
|
@@ -65,28 +60,27 @@ wrapped stream buffer object.
|
|
| 65 |
basic_syncbuf(streambuf_type* obuf, const Allocator& allocator);
|
| 66 |
```
|
| 67 |
|
| 68 |
*Effects:* Sets `wrapped` to `obuf`.
|
| 69 |
|
| 70 |
-
*Remarks:* A copy of `allocator` is used to allocate memory for internal
|
| 71 |
-
buffers holding the associated output.
|
| 72 |
-
|
| 73 |
-
*Throws:* Nothing unless an exception is thrown by the construction of a
|
| 74 |
-
mutex or by memory allocation.
|
| 75 |
-
|
| 76 |
*Ensures:* `get_wrapped() == obuf` and `get_allocator() == allocator`
|
| 77 |
are `true`.
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
``` cpp
|
| 80 |
basic_syncbuf(basic_syncbuf&& other);
|
| 81 |
```
|
| 82 |
|
| 83 |
*Ensures:* The value returned by `this->get_wrapped()` is the value
|
| 84 |
returned by `other.get_wrapped()` prior to calling this constructor.
|
| 85 |
Output stored in `other` prior to calling this constructor will be
|
| 86 |
-
stored in `*this` afterwards.
|
| 87 |
-
`other.rdbuf()->pbase() == other.rdbuf()->pptr()` and
|
| 88 |
`other.get_wrapped() == nullptr` are `true`.
|
| 89 |
|
| 90 |
*Remarks:* This constructor disassociates `other` from its wrapped
|
| 91 |
stream buffer, ensuring destruction of `other` produces no output.
|
| 92 |
|
|
@@ -100,34 +94,34 @@ stream buffer, ensuring destruction of `other` produces no output.
|
|
| 100 |
destructor catches and ignores that exception.
|
| 101 |
|
| 102 |
#### Assignment and swap <a id="syncstream.syncbuf.assign">[[syncstream.syncbuf.assign]]</a>
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
-
basic_syncbuf& operator=(basic_syncbuf&& rhs)
|
| 106 |
```
|
| 107 |
|
| 108 |
*Effects:* Calls `emit()` then move assigns from `rhs`. After the move
|
| 109 |
assignment `*this` has the observable state it would have had if it had
|
| 110 |
been move constructed from `rhs` [[syncstream.syncbuf.cons]].
|
| 111 |
|
| 112 |
-
*Returns:* `*this`.
|
| 113 |
-
|
| 114 |
*Ensures:*
|
| 115 |
|
| 116 |
- `rhs.get_wrapped() == nullptr` is `true`.
|
| 117 |
- `this->get_allocator() == rhs.get_allocator()` is `true` when
|
| 118 |
``` cpp
|
| 119 |
allocator_traits<Allocator>::propagate_on_container_move_assignment::value
|
| 120 |
```
|
| 121 |
|
| 122 |
is `true`; otherwise, the allocator is unchanged.
|
| 123 |
|
|
|
|
|
|
|
| 124 |
*Remarks:* This assignment operator disassociates `rhs` from its wrapped
|
| 125 |
stream buffer, ensuring destruction of `rhs` produces no output.
|
| 126 |
|
| 127 |
``` cpp
|
| 128 |
-
void swap(basic_syncbuf& other)
|
| 129 |
```
|
| 130 |
|
| 131 |
*Preconditions:* Either
|
| 132 |
`allocator_traits<Allocator>::propagate_on_container_swap::value` is
|
| 133 |
`true` or `this->get_allocator() == other.get_allocator()` is `true`.
|
|
@@ -144,25 +138,25 @@ bool emit();
|
|
| 144 |
stream buffer `*wrapped`, so that it appears in the output stream as a
|
| 145 |
contiguous sequence of characters. `wrapped->pubsync()` is called if and
|
| 146 |
only if a call was made to `sync()` since the most recent call to
|
| 147 |
`emit()`, if any.
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
*Returns:* `true` if all of the following conditions hold; otherwise
|
| 150 |
`false`:
|
| 151 |
|
| 152 |
- `wrapped == nullptr` is `false`.
|
| 153 |
- All of the characters in the associated output were successfully
|
| 154 |
transferred.
|
| 155 |
- The call to `wrapped->pubsync()` (if any) succeeded.
|
| 156 |
|
| 157 |
-
*Ensures:* On success, the associated output is empty.
|
| 158 |
-
|
| 159 |
-
*Synchronization:* All `emit()` calls transferring characters to the
|
| 160 |
-
same stream buffer object appear to execute in a total order consistent
|
| 161 |
-
with the “happens before” relation [[intro.races]], where each `emit()`
|
| 162 |
-
call synchronizes with subsequent `emit()` calls in that total order.
|
| 163 |
-
|
| 164 |
*Remarks:* May call member functions of `wrapped` while holding a lock
|
| 165 |
uniquely associated with `wrapped`.
|
| 166 |
|
| 167 |
``` cpp
|
| 168 |
streambuf_type* get_wrapped() const noexcept;
|
|
@@ -201,10 +195,10 @@ otherwise `0`.
|
|
| 201 |
#### Specialized algorithms <a id="syncstream.syncbuf.special">[[syncstream.syncbuf.special]]</a>
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
template<class charT, class traits, class Allocator>
|
| 205 |
void swap(basic_syncbuf<charT, traits, Allocator>& a,
|
| 206 |
-
basic_syncbuf<charT, traits, Allocator>& b)
|
| 207 |
```
|
| 208 |
|
| 209 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 210 |
|
|
|
|
| 41 |
|
| 42 |
private:
|
| 43 |
streambuf_type* wrapped; // exposition only
|
| 44 |
bool emit_on_sync{}; // exposition only
|
| 45 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
```
|
| 48 |
|
| 49 |
Class template `basic_syncbuf` stores character data written to it,
|
| 50 |
known as the associated output, into internal buffers allocated using
|
|
|
|
| 60 |
basic_syncbuf(streambuf_type* obuf, const Allocator& allocator);
|
| 61 |
```
|
| 62 |
|
| 63 |
*Effects:* Sets `wrapped` to `obuf`.
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
*Ensures:* `get_wrapped() == obuf` and `get_allocator() == allocator`
|
| 66 |
are `true`.
|
| 67 |
|
| 68 |
+
*Throws:* Nothing unless an exception is thrown by the construction of a
|
| 69 |
+
mutex or by memory allocation.
|
| 70 |
+
|
| 71 |
+
*Remarks:* A copy of `allocator` is used to allocate memory for internal
|
| 72 |
+
buffers holding the associated output.
|
| 73 |
+
|
| 74 |
``` cpp
|
| 75 |
basic_syncbuf(basic_syncbuf&& other);
|
| 76 |
```
|
| 77 |
|
| 78 |
*Ensures:* The value returned by `this->get_wrapped()` is the value
|
| 79 |
returned by `other.get_wrapped()` prior to calling this constructor.
|
| 80 |
Output stored in `other` prior to calling this constructor will be
|
| 81 |
+
stored in `*this` afterwards. `other.pbase() == other.pptr()` and
|
|
|
|
| 82 |
`other.get_wrapped() == nullptr` are `true`.
|
| 83 |
|
| 84 |
*Remarks:* This constructor disassociates `other` from its wrapped
|
| 85 |
stream buffer, ensuring destruction of `other` produces no output.
|
| 86 |
|
|
|
|
| 94 |
destructor catches and ignores that exception.
|
| 95 |
|
| 96 |
#### Assignment and swap <a id="syncstream.syncbuf.assign">[[syncstream.syncbuf.assign]]</a>
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
+
basic_syncbuf& operator=(basic_syncbuf&& rhs);
|
| 100 |
```
|
| 101 |
|
| 102 |
*Effects:* Calls `emit()` then move assigns from `rhs`. After the move
|
| 103 |
assignment `*this` has the observable state it would have had if it had
|
| 104 |
been move constructed from `rhs` [[syncstream.syncbuf.cons]].
|
| 105 |
|
|
|
|
|
|
|
| 106 |
*Ensures:*
|
| 107 |
|
| 108 |
- `rhs.get_wrapped() == nullptr` is `true`.
|
| 109 |
- `this->get_allocator() == rhs.get_allocator()` is `true` when
|
| 110 |
``` cpp
|
| 111 |
allocator_traits<Allocator>::propagate_on_container_move_assignment::value
|
| 112 |
```
|
| 113 |
|
| 114 |
is `true`; otherwise, the allocator is unchanged.
|
| 115 |
|
| 116 |
+
*Returns:* `*this`.
|
| 117 |
+
|
| 118 |
*Remarks:* This assignment operator disassociates `rhs` from its wrapped
|
| 119 |
stream buffer, ensuring destruction of `rhs` produces no output.
|
| 120 |
|
| 121 |
``` cpp
|
| 122 |
+
void swap(basic_syncbuf& other);
|
| 123 |
```
|
| 124 |
|
| 125 |
*Preconditions:* Either
|
| 126 |
`allocator_traits<Allocator>::propagate_on_container_swap::value` is
|
| 127 |
`true` or `this->get_allocator() == other.get_allocator()` is `true`.
|
|
|
|
| 138 |
stream buffer `*wrapped`, so that it appears in the output stream as a
|
| 139 |
contiguous sequence of characters. `wrapped->pubsync()` is called if and
|
| 140 |
only if a call was made to `sync()` since the most recent call to
|
| 141 |
`emit()`, if any.
|
| 142 |
|
| 143 |
+
*Synchronization:* All `emit()` calls transferring characters to the
|
| 144 |
+
same stream buffer object appear to execute in a total order consistent
|
| 145 |
+
with the “happens before” relation [[intro.races]], where each `emit()`
|
| 146 |
+
call synchronizes with subsequent `emit()` calls in that total order.
|
| 147 |
+
|
| 148 |
+
*Ensures:* On success, the associated output is empty.
|
| 149 |
+
|
| 150 |
*Returns:* `true` if all of the following conditions hold; otherwise
|
| 151 |
`false`:
|
| 152 |
|
| 153 |
- `wrapped == nullptr` is `false`.
|
| 154 |
- All of the characters in the associated output were successfully
|
| 155 |
transferred.
|
| 156 |
- The call to `wrapped->pubsync()` (if any) succeeded.
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
*Remarks:* May call member functions of `wrapped` while holding a lock
|
| 159 |
uniquely associated with `wrapped`.
|
| 160 |
|
| 161 |
``` cpp
|
| 162 |
streambuf_type* get_wrapped() const noexcept;
|
|
|
|
| 195 |
#### Specialized algorithms <a id="syncstream.syncbuf.special">[[syncstream.syncbuf.special]]</a>
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
template<class charT, class traits, class Allocator>
|
| 199 |
void swap(basic_syncbuf<charT, traits, Allocator>& a,
|
| 200 |
+
basic_syncbuf<charT, traits, Allocator>& b);
|
| 201 |
```
|
| 202 |
|
| 203 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 204 |
|