Skip to content

34 files changed

+2656
-26
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Status
442442
--------------------------------------------------- -----------------
443443
``__cpp_lib_span_initializer_list`` ``202311L``
444444
--------------------------------------------------- -----------------
445-
``__cpp_lib_sstream_from_string_view`` *unimplemented*
445+
``__cpp_lib_sstream_from_string_view`` ``202306L``
446446
--------------------------------------------------- -----------------
447447
``__cpp_lib_submdspan`` *unimplemented*
448448
--------------------------------------------------- -----------------

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Implemented Papers
4141
- P2637R3 - Member ``visit``
4242
- P2652R2 - Disallow User Specialization of ``allocator_traits``
4343
- P2819R2 - Add ``tuple`` protocol to ``complex``
44+
- P2495R3 - Interfacing ``stringstream``s with ``string_view``
4445
- P2302R4 - ``std::ranges::contains``
4546
- P1659R3 - ``std::ranges::starts_with`` and ``std::ranges::ends_with``
4647

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"`P2545R4 <https://wg21.link/P2545R4>`__","LWG","Read-Copy Update (RCU)","Varna June 2023","","",""
77
"`P2530R3 <https://wg21.link/P2530R3>`__","LWG","Hazard Pointers for C++26","Varna June 2023","","",""
88
"`P2538R1 <https://wg21.link/P2538R1>`__","LWG","ADL-proof ``std::projected``","Varna June 2023","|Complete|","18.0","|ranges|"
9-
"`P2495R3 <https://wg21.link/P2495R3>`__","LWG","Interfacing ``stringstreams`` with ``string_view``","Varna June 2023","","",""
9+
"`P2495R3 <https://wg21.link/P2495R3>`__","LWG","Interfacing ``stringstream``s with ``string_view``","Varna June 2023","|Complete|","19.0",""
1010
"`P2510R3 <https://wg21.link/P2510R3>`__","LWG","Formatting pointers","Varna June 2023","|Complete| [#note-P2510R3]_","17.0","|format|"
1111
"`P2198R7 <https://wg21.link/P2198R7>`__","LWG","Freestanding Feature-Test Macros and Implementation-Defined Extensions","Varna June 2023","","",""
1212
"`P2338R4 <https://wg21.link/P2338R4>`__","LWG","Freestanding Library: Character primitives and the C library","Varna June 2023","","",""

libcxx/include/sstream

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public:
4848
template <class SAlloc>
4949
explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
5050
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
5158
basic_stringbuf(const basic_stringbuf&) = delete;
5259
basic_stringbuf(basic_stringbuf&& rhs);
5360
basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20
@@ -69,6 +76,8 @@ public:
6976
template <class SAlloc>
7077
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
7178
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
7281
7382
protected:
7483
// [stringbuf.virtuals] Overridden virtual functions:
@@ -121,6 +130,12 @@ public:
121130
template <class SAlloc>
122131
explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
123132
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
124139
basic_istringstream(const basic_istringstream&) = delete;
125140
basic_istringstream(basic_istringstream&& rhs);
126141
@@ -141,6 +156,8 @@ public:
141156
template <class SAlloc>
142157
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
143158
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
144161
};
145162
146163
template <class charT, class traits, class Allocator>
@@ -182,6 +199,12 @@ public:
182199
template <class SAlloc>
183200
explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
184201
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
185208
basic_ostringstream(const basic_ostringstream&) = delete;
186209
basic_ostringstream(basic_ostringstream&& rhs);
187210
@@ -202,6 +225,8 @@ public:
202225
template <class SAlloc>
203226
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
204227
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
205230
};
206231
207232
template <class charT, class traits, class Allocator>
@@ -243,6 +268,13 @@ public:
243268
template <class SAlloc>
244269
explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
245270
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
246278
basic_stringstream(const basic_stringstream&) = delete;
247279
basic_stringstream(basic_stringstream&& rhs);
248280
@@ -263,6 +295,8 @@ public:
263295
template <class SAlloc>
264296
void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
265297
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
266300
};
267301
268302
template <class charT, class traits, class Allocator>
@@ -281,10 +315,12 @@ typedef basic_stringstream<wchar_t> wstringstream;
281315
#include <__availability>
282316
#include <__config>
283317
#include <__fwd/sstream.h>
318+
#include <__type_traits/is_convertible.h>
284319
#include <__utility/swap.h>
285320
#include <istream>
286321
#include <ostream>
287322
#include <string>
323+
#include <string_view>
288324
#include <version>
289325

290326
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -371,6 +407,30 @@ public:
371407
}
372408
#endif // _LIBCPP_STD_VER >= 20
373409

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+
374434
basic_stringbuf(const basic_stringbuf&) = delete;
375435
basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
376436

@@ -444,6 +504,18 @@ public:
444504
}
445505
#endif // _LIBCPP_STD_VER >= 20
446506

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+
447519
protected:
448520
// [stringbuf.virtuals] Overridden virtual functions:
449521
int_type underflow() override;
@@ -831,6 +903,25 @@ public:
831903
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
832904
#endif // _LIBCPP_STD_VER >= 20
833905

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+
834925
basic_istringstream(const basic_istringstream&) = delete;
835926
_LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
836927
: basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -882,6 +973,14 @@ public:
882973

883974
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
884975
#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
885984
};
886985

887986
template <class _CharT, class _Traits, class _Allocator>
@@ -940,6 +1039,25 @@ public:
9401039
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
9411040
#endif // _LIBCPP_STD_VER >= 20
9421041

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+
9431061
basic_ostringstream(const basic_ostringstream&) = delete;
9441062
_LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
9451063
: basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -992,6 +1110,14 @@ public:
9921110

9931111
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
9941112
#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
9951121
};
9961122

9971123
template <class _CharT, class _Traits, class _Allocator>
@@ -1053,6 +1179,26 @@ public:
10531179
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
10541180
#endif // _LIBCPP_STD_VER >= 20
10551181

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+
10561202
basic_stringstream(const basic_stringstream&) = delete;
10571203
_LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
10581204
: basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
@@ -1104,6 +1250,14 @@ public:
11041250

11051251
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
11061252
#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
11071261
};
11081262

11091263
template <class _CharT, class _Traits, class _Allocator>

libcxx/include/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
515515
// # define __cpp_lib_smart_ptr_owner_equality 202306L
516516
# define __cpp_lib_span_at 202311L
517517
# define __cpp_lib_span_initializer_list 202311L
518-
// # define __cpp_lib_sstream_from_string_view 202306L
518+
# define __cpp_lib_sstream_from_string_view 202306L
519519
// # define __cpp_lib_submdspan 202306L
520520
// # define __cpp_lib_text_encoding 202306L
521521
# undef __cpp_lib_to_chars

libcxx/test/libcxx/transitive_includes/cxx03.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ sstream cstddef
745745
sstream istream
746746
sstream ostream
747747
sstream string
748+
sstream string_view
748749
sstream type_traits
749750
sstream version
750751
stack compare

libcxx/test/libcxx/transitive_includes/cxx11.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ sstream cstddef
751751
sstream istream
752752
sstream ostream
753753
sstream string
754+
sstream string_view
754755
sstream type_traits
755756
sstream version
756757
stack compare

libcxx/test/libcxx/transitive_includes/cxx14.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ sstream cstddef
753753
sstream istream
754754
sstream ostream
755755
sstream string
756+
sstream string_view
756757
sstream type_traits
757758
sstream version
758759
stack compare

libcxx/test/libcxx/transitive_includes/cxx17.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ sstream cstddef
753753
sstream istream
754754
sstream ostream
755755
sstream string
756+
sstream string_view
756757
sstream type_traits
757758
sstream version
758759
stack compare

libcxx/test/libcxx/transitive_includes/cxx20.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ sstream cstddef
758758
sstream istream
759759
sstream ostream
760760
sstream string
761+
sstream string_view
761762
sstream type_traits
762763
sstream version
763764
stack compare

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ sstream cstddef
519519
sstream istream
520520
sstream ostream
521521
sstream string
522+
sstream string_view
522523
sstream version
523524
stack compare
524525
stack cstddef

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ sstream cstddef
519519
sstream istream
520520
sstream ostream
521521
sstream string
522+
sstream string_view
522523
sstream version
523524
stack compare
524525
stack cstddef
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H
10+
#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H
11+
12+
template <typename S, typename T>
13+
concept is_valid_argument_for_str_member = requires(S s, const T& sv) {
14+
{ s.str(sv) };
15+
};
16+
17+
#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H

0 commit comments

Comments
 (0)