@@ -48,6 +48,13 @@ public:
48
48
template <class SAlloc>
49
49
explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
50
50
ios_base::openmode which = ios_base::in | ios_base::out); // C++20
51
+ template<class T>
52
+ explicit basic_stringbuf(const T& t,
53
+ ios_base::openmode which = ios_base::in | ios_base::out); // Since C++26
54
+ template<class T>
55
+ basic_stringbuf(const T& t, const Allocator& a); // Since C++26
56
+ template<class T>
57
+ basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
51
58
basic_stringbuf(const basic_stringbuf&) = delete;
52
59
basic_stringbuf(basic_stringbuf&& rhs);
53
60
basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20
@@ -69,6 +76,8 @@ public:
69
76
template <class SAlloc>
70
77
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
71
78
void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
79
+ template<class T>
80
+ void str(const T& t); // Since C++26
72
81
73
82
protected:
74
83
// [stringbuf.virtuals] Overridden virtual functions:
@@ -121,6 +130,12 @@ public:
121
130
template <class SAlloc>
122
131
explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
123
132
ios_base::openmode which = ios_base::in); // C++20
133
+ template<class T>
134
+ explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in); // Since C++26
135
+ template<class T>
136
+ basic_istringstream(const T& t, const Allocator& a); // Since C++26
137
+ template<class T>
138
+ basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
124
139
basic_istringstream(const basic_istringstream&) = delete;
125
140
basic_istringstream(basic_istringstream&& rhs);
126
141
@@ -141,6 +156,8 @@ public:
141
156
template <class SAlloc>
142
157
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
143
158
void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
159
+ template<class T>
160
+ void str(const T& t); // Since C++26
144
161
};
145
162
146
163
template <class charT, class traits, class Allocator>
@@ -182,6 +199,12 @@ public:
182
199
template <class SAlloc>
183
200
explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
184
201
ios_base::openmode which = ios_base::out); // C++20
202
+ template<class T>
203
+ explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); // Since C++26
204
+ template<class T>
205
+ basic_ostringstream(const T& t, const Allocator& a); // Since C++26
206
+ template<class T>
207
+ basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
185
208
basic_ostringstream(const basic_ostringstream&) = delete;
186
209
basic_ostringstream(basic_ostringstream&& rhs);
187
210
@@ -202,6 +225,8 @@ public:
202
225
template <class SAlloc>
203
226
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
204
227
void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
228
+ template<class T>
229
+ void str(const T& t); // Since C++26
205
230
};
206
231
207
232
template <class charT, class traits, class Allocator>
@@ -243,6 +268,13 @@ public:
243
268
template <class SAlloc>
244
269
explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
245
270
ios_base::openmode which = ios_base::out | ios_base::in); // C++20
271
+ template<class T>
272
+ explicit basic_stringstream(const T& t,
273
+ ios_base::openmode which = ios_base::out | ios_base::in); // Since C++26
274
+ template<class T>
275
+ basic_stringstream(const T& t, const Allocator& a); // Since C++26
276
+ template<class T>
277
+ basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
246
278
basic_stringstream(const basic_stringstream&) = delete;
247
279
basic_stringstream(basic_stringstream&& rhs);
248
280
@@ -263,6 +295,8 @@ public:
263
295
template <class SAlloc>
264
296
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
265
297
void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
298
+ template<class T>
299
+ void str(const T& t); // Since C++26
266
300
};
267
301
268
302
template <class charT, class traits, class Allocator>
@@ -281,10 +315,12 @@ typedef basic_stringstream<wchar_t> wstringstream;
281
315
#include < __availability>
282
316
#include < __config>
283
317
#include < __fwd/sstream.h>
318
+ #include < __type_traits/is_convertible.h>
284
319
#include < __utility/swap.h>
285
320
#include < istream>
286
321
#include < ostream>
287
322
#include < string>
323
+ #include < string_view>
288
324
#include < version>
289
325
290
326
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -371,6 +407,30 @@ public:
371
407
}
372
408
#endif // _LIBCPP_STD_VER >= 20
373
409
410
+ #if _LIBCPP_STD_VER >= 26
411
+
412
+ template <class _Tp >
413
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
414
+ _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf (const _Tp& __t ,
415
+ ios_base::openmode __which = ios_base::in | ios_base::out)
416
+ : basic_stringbuf(__t , __which, _Allocator()) {}
417
+
418
+ template <class _Tp >
419
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
420
+ _LIBCPP_HIDE_FROM_ABI basic_stringbuf (const _Tp& __t , const _Allocator& __a)
421
+ : basic_stringbuf(__t , ios_base::in | ios_base::out, __a) {}
422
+
423
+ template <class _Tp >
424
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
425
+ _LIBCPP_HIDE_FROM_ABI basic_stringbuf (const _Tp& __t , ios_base::openmode __which, const _Allocator& __a)
426
+ : __hm_(nullptr ), __mode_(__which) {
427
+ basic_string_view<_CharT, _Traits> __sv = __t ;
428
+ __str_ = string_type (__sv, __a);
429
+ __init_buf_ptrs ();
430
+ }
431
+
432
+ #endif // _LIBCPP_STD_VER >= 26
433
+
374
434
basic_stringbuf (const basic_stringbuf&) = delete ;
375
435
basic_stringbuf (basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init (std::move (__rhs)); }
376
436
@@ -444,6 +504,18 @@ public:
444
504
}
445
505
#endif // _LIBCPP_STD_VER >= 20
446
506
507
+ #if _LIBCPP_STD_VER >= 26
508
+
509
+ template <class _Tp >
510
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
511
+ _LIBCPP_HIDE_FROM_ABI void str (const _Tp& __t ) {
512
+ basic_string_view<_CharT, _Traits> __sv = __t ;
513
+ __str_ = __sv;
514
+ __init_buf_ptrs ();
515
+ }
516
+
517
+ #endif // _LIBCPP_STD_VER >= 26
518
+
447
519
protected:
448
520
// [stringbuf.virtuals] Overridden virtual functions:
449
521
int_type underflow () override ;
@@ -831,6 +903,25 @@ public:
831
903
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
832
904
#endif // _LIBCPP_STD_VER >= 20
833
905
906
+ #if _LIBCPP_STD_VER >= 26
907
+
908
+ template <class _Tp >
909
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
910
+ _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream (const _Tp& __t , ios_base::openmode __which = ios_base::in)
911
+ : basic_istringstream(__t , __which, _Allocator()) {}
912
+
913
+ template <class _Tp >
914
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
915
+ _LIBCPP_HIDE_FROM_ABI basic_istringstream (const _Tp& __t , const _Allocator& __a)
916
+ : basic_istringstream(__t , ios_base::in, __a) {}
917
+
918
+ template <class _Tp >
919
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
920
+ _LIBCPP_HIDE_FROM_ABI basic_istringstream (const _Tp& __t , ios_base::openmode __which, const _Allocator& __a)
921
+ : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t , __which | ios_base::in, __a) {}
922
+
923
+ #endif // _LIBCPP_STD_VER >= 26
924
+
834
925
basic_istringstream (const basic_istringstream&) = delete ;
835
926
_LIBCPP_HIDE_FROM_ABI basic_istringstream (basic_istringstream&& __rhs)
836
927
: basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -882,6 +973,14 @@ public:
882
973
883
974
_LIBCPP_HIDE_FROM_ABI void str (string_type&& __s) { __sb_.str (std::move (__s)); }
884
975
#endif // _LIBCPP_STD_VER >= 20
976
+
977
+ #if _LIBCPP_STD_VER >= 26
978
+ template <class _Tp >
979
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
980
+ _LIBCPP_HIDE_FROM_ABI void str (const _Tp& __t ) {
981
+ rdbuf ()->str (__t );
982
+ }
983
+ #endif // _LIBCPP_STD_VER >= 26
885
984
};
886
985
887
986
template <class _CharT , class _Traits , class _Allocator >
@@ -940,6 +1039,25 @@ public:
940
1039
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
941
1040
#endif // _LIBCPP_STD_VER >= 20
942
1041
1042
+ #if _LIBCPP_STD_VER >= 26
1043
+
1044
+ template <class _Tp >
1045
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1046
+ _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream (const _Tp& __t , ios_base::openmode __which = ios_base::out)
1047
+ : basic_ostringstream(__t , __which | ios_base::out, _Allocator()) {}
1048
+
1049
+ template <class _Tp >
1050
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1051
+ _LIBCPP_HIDE_FROM_ABI basic_ostringstream (const _Tp& __t , const _Allocator& __a)
1052
+ : basic_ostringstream(__t , ios_base::out, __a) {}
1053
+
1054
+ template <class _Tp >
1055
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1056
+ _LIBCPP_HIDE_FROM_ABI basic_ostringstream (const _Tp& __t , ios_base::openmode __which, const _Allocator& __a)
1057
+ : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t , __which | ios_base::out, __a) {}
1058
+
1059
+ #endif // _LIBCPP_STD_VER >= 26
1060
+
943
1061
basic_ostringstream (const basic_ostringstream&) = delete ;
944
1062
_LIBCPP_HIDE_FROM_ABI basic_ostringstream (basic_ostringstream&& __rhs)
945
1063
: basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -992,6 +1110,14 @@ public:
992
1110
993
1111
_LIBCPP_HIDE_FROM_ABI void str (string_type&& __s) { __sb_.str (std::move (__s)); }
994
1112
#endif // _LIBCPP_STD_VER >= 20
1113
+
1114
+ #if _LIBCPP_STD_VER >= 26
1115
+ template <class _Tp >
1116
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1117
+ _LIBCPP_HIDE_FROM_ABI void str (const _Tp& __t ) {
1118
+ rdbuf ()->str (__t );
1119
+ }
1120
+ #endif // _LIBCPP_STD_VER >= 26
995
1121
};
996
1122
997
1123
template <class _CharT , class _Traits , class _Allocator >
@@ -1053,6 +1179,26 @@ public:
1053
1179
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
1054
1180
#endif // _LIBCPP_STD_VER >= 20
1055
1181
1182
+ #if _LIBCPP_STD_VER >= 26
1183
+
1184
+ template <class _Tp >
1185
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1186
+ _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream (const _Tp& __t ,
1187
+ ios_base::openmode __which = ios_base::out | ios_base::in)
1188
+ : basic_stringstream(__t , __which, _Allocator()) {}
1189
+
1190
+ template <class _Tp >
1191
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1192
+ _LIBCPP_HIDE_FROM_ABI basic_stringstream (const _Tp& __t , const _Allocator& __a)
1193
+ : basic_stringstream(__t , ios_base::out | ios_base::in, __a) {}
1194
+
1195
+ template <class _Tp >
1196
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1197
+ _LIBCPP_HIDE_FROM_ABI basic_stringstream (const _Tp& __t , ios_base::openmode __which, const _Allocator& __a)
1198
+ : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t , __which, __a) {}
1199
+
1200
+ #endif // _LIBCPP_STD_VER >= 26
1201
+
1056
1202
basic_stringstream (const basic_stringstream&) = delete ;
1057
1203
_LIBCPP_HIDE_FROM_ABI basic_stringstream (basic_stringstream&& __rhs)
1058
1204
: basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -1104,6 +1250,14 @@ public:
1104
1250
1105
1251
_LIBCPP_HIDE_FROM_ABI void str (string_type&& __s) { __sb_.str (std::move (__s)); }
1106
1252
#endif // _LIBCPP_STD_VER >= 20
1253
+
1254
+ #if _LIBCPP_STD_VER >= 26
1255
+ template <class _Tp >
1256
+ requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1257
+ _LIBCPP_HIDE_FROM_ABI void str (const _Tp& __t ) {
1258
+ rdbuf ()->str (__t );
1259
+ }
1260
+ #endif // _LIBCPP_STD_VER >= 26
1107
1261
};
1108
1262
1109
1263
template <class _CharT , class _Traits , class _Allocator >
0 commit comments