Skip to content

Commit 8458260

Browse files
committed
libstdc++: sstream from string_view (P2495R3) [PR119741]
Add constructors to stringbuf, stringstream, istringstream, and ostringstream, and a matching overload of str(sv) in each, that take anything convertible to a string_view in places where the existing ctors and function take a string. Note this change omits the constraint applied to the istringstream constructor from string cited as a "drive-by" in P2495R3, as we have determined it is redundant. libstdc++-v3/ChangeLog: PR libstdc++/119741 * include/std/sstream: full implementation, really just decls, requires clause and plumbing. * include/bits/version.def, include/bits/version.h: new preprocessor symbol __cpp_lib_sstream_from_string_view. * testsuite/27_io/basic_stringbuf/cons/char/string_view.cc: New tests. * testsuite/27_io/basic_istringstream/cons/char/string_view.cc: New tests. * testsuite/27_io/basic_ostringstream/cons/char/string_view.cc: New tests. * testsuite/27_io/basic_stringstream/cons/char/string_view.cc: New tests. * testsuite/27_io/basic_stringbuf/cons/wchar_t/string_view.cc: New tests. * testsuite/27_io/basic_istringstream/cons/wchar_t/string_view.cc: New tests. * testsuite/27_io/basic_ostringstream/cons/wchar_t/string_view.cc: New tests. * testsuite/27_io/basic_stringstream/cons/wchar_t/string_view.cc: New tests. Reviewed-by: Jonathan Wakely
1 parent cdfa5fe commit 8458260

File tree

11 files changed

+1026
-19
lines changed

11 files changed

+1026
-19
lines changed

libstdc++-v3/include/bits/version.def

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ ftms = {
649649
};
650650
values = {
651651
v = 1;
652-
/* For when there's no gthread. */
652+
// For when there is no gthread.
653653
cxxmin = 17;
654654
hosted = yes;
655655
gthread = no;
@@ -1995,6 +1995,15 @@ ftms = {
19951995
};
19961996
};
19971997

1998+
ftms = {
1999+
name = sstream_from_string_view;
2000+
values = {
2001+
v = 202306;
2002+
cxxmin = 26;
2003+
hosted = yes;
2004+
};
2005+
};
2006+
19982007
// Standard test specifications.
19992008
stds[97] = ">= 199711L";
20002009
stds[03] = ">= 199711L";

libstdc++-v3/include/bits/version.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,4 +2233,14 @@
22332233
#endif /* !defined(__cpp_lib_polymorphic) && defined(__glibcxx_want_polymorphic) */
22342234
#undef __glibcxx_want_polymorphic
22352235

2236+
#if !defined(__cpp_lib_sstream_from_string_view)
2237+
# if (__cplusplus > 202302L) && _GLIBCXX_HOSTED
2238+
# define __glibcxx_sstream_from_string_view 202306L
2239+
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_sstream_from_string_view)
2240+
# define __cpp_lib_sstream_from_string_view 202306L
2241+
# endif
2242+
# endif
2243+
#endif /* !defined(__cpp_lib_sstream_from_string_view) && defined(__glibcxx_want_sstream_from_string_view) */
2244+
#undef __glibcxx_want_sstream_from_string_view
2245+
22362246
#undef __glibcxx_want_all

0 commit comments

Comments
 (0)