@@ -99,12 +99,12 @@ public:
99
99
_LIBCPP_HIDE_FROM_ABI basic_spanbuf () : basic_spanbuf(ios_base::in | ios_base::out) {}
100
100
101
101
_LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf (ios_base::openmode __which)
102
- : basic_streambuf <_CharT, _Traits>{}, __mode_{ __which} {}
102
+ : basic_spanbuf(std::span <_CharT>(), __which) {}
103
103
104
104
_LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf (std::span<_CharT> __s,
105
105
ios_base::openmode __which = ios_base::in | ios_base::out)
106
- : basic_streambuf<_CharT, _Traits>{}, __mode_{ __which} {
107
- this -> span (__s);
106
+ : basic_streambuf<_CharT, _Traits>{}, __mode_( __which) {
107
+ span (__s);
108
108
}
109
109
110
110
basic_spanbuf (const basic_spanbuf&) = delete ;
@@ -113,14 +113,15 @@ public:
113
113
: basic_streambuf<_CharT, _Traits>{std::move (__rhs)},
114
114
__mode_{std::move (__rhs.__mode_ )},
115
115
__buf_{std::move (__rhs.__buf_ )} {}
116
+ // __buf_{std::exchange(__rhs.__buf_, {})} {}
116
117
117
118
// [spanbuf.assign], assignment and swap
118
119
119
120
basic_spanbuf& operator =(const basic_spanbuf&) = delete ;
120
121
121
122
_LIBCPP_HIDE_FROM_ABI basic_spanbuf& operator =(basic_spanbuf&& __rhs) {
122
123
basic_spanbuf __tmp{std::move (__rhs)};
123
- this -> swap (__tmp);
124
+ swap (__tmp);
124
125
return *this ;
125
126
}
126
127
@@ -134,7 +135,7 @@ public:
134
135
135
136
_LIBCPP_HIDE_FROM_ABI std::span<_CharT> span () const noexcept {
136
137
if (__mode_ & ios_base::out) {
137
- return std::span<_CharT>( this ->pbase (), this ->pptr ()) ;
138
+ return std::span<_CharT>{ this ->pbase (), this ->pptr ()} ;
138
139
}
139
140
return __buf_;
140
141
}
@@ -158,38 +159,38 @@ protected:
158
159
// [spanbuf.virtuals], overridden virtual functions
159
160
160
161
_LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* setbuf (_CharT* __s, streamsize __n) override {
161
- this -> span (std::span<_CharT>(__s, __n));
162
+ span (std::span<_CharT>(__s, __n));
162
163
return this ;
163
164
}
164
165
165
166
_LIBCPP_HIDE_FROM_ABI pos_type
166
167
seekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override {
167
- const pos_type __error (off_type (- 1 ) );
168
+ const auto __error = static_cast <pos_type> (off_type{- 1 } );
168
169
169
170
if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way))
170
171
return __error;
171
172
172
173
// Calculate __baseoff
173
174
174
- off_type __baseoff;
175
+ std:: size_t __baseoff;
175
176
176
177
switch (__way) {
177
178
case ios_base::beg:
178
- __baseoff = off_type ( 0 ) ;
179
+ __baseoff = 0Z ;
179
180
break ;
180
181
181
182
case ios_base::cur:
182
183
if (__which & ios_base::out)
183
- __baseoff = off_type ( this ->pptr () - this ->pbase () );
184
+ __baseoff = this ->pptr () - this ->pbase ();
184
185
else
185
- __baseoff = off_type ( this ->gptr () - this ->eback () );
186
+ __baseoff = this ->gptr () - this ->eback ();
186
187
break ;
187
188
188
189
case ios_base::end:
189
190
if ((__which & ios_base::out) && !(__which & ios_base::in))
190
- __baseoff = off_type ( this ->pptr () - this ->pbase () );
191
+ __baseoff = this ->pptr () - this ->pbase ();
191
192
else
192
- __baseoff = off_type ( __buf_.size () );
193
+ __baseoff = __buf_.size ();
193
194
break ;
194
195
195
196
default :
@@ -200,29 +201,29 @@ protected:
200
201
201
202
off_type __newoff;
202
203
203
- if (__builtin_add_overflow (__baseoff, __off, &__newoff) || (__newoff < off_type ( 0 ) ) ||
204
- ( std::cmp_greater (__newoff, __buf_.size () )))
204
+ if (__builtin_add_overflow (__baseoff, __off, &__newoff) || (__newoff < off_type{ 0 } ) ||
205
+ std::cmp_greater (__newoff, __buf_.size ()))
205
206
return __error;
206
207
207
208
if (__which & ios_base::in) {
208
- if ((this ->gptr () == nullptr ) && (__newoff != off_type ( 0 ) ))
209
+ if ((this ->gptr () == nullptr ) && (__newoff != off_type{ 0 } ))
209
210
return __error;
210
211
this ->setg (this ->eback (), this ->eback () + __newoff, this ->egptr ());
211
212
}
212
213
213
214
if (__which & ios_base::out) {
214
- if ((this ->pptr () == nullptr ) && (__newoff != off_type ( 0 ) ))
215
+ if ((this ->pptr () == nullptr ) && (__newoff != off_type{ 0 } ))
215
216
return __error;
216
217
this ->setp (this ->pbase (), this ->epptr ());
217
218
this ->pbump (__newoff);
218
219
}
219
220
220
- return pos_type (__newoff);
221
+ return static_cast < pos_type> (__newoff);
221
222
}
222
223
223
224
_LIBCPP_HIDE_FROM_ABI pos_type seekpos (pos_type __sp,
224
225
ios_base::openmode __which = ios_base::in | ios_base::out) override {
225
- return seekoff (off_type (__sp), ios_base::beg, __which);
226
+ return seekoff (static_cast < off_type> (__sp), ios_base::beg, __which);
226
227
}
227
228
228
229
private:
0 commit comments