* [PATCH] libstdc++: Implement C++20 features for <sstream>
@ 2020-10-07 16:55 Thomas Rodgers
2020-10-07 19:44 ` Jonathan Wakely
2020-11-04 19:54 ` Stephan Bergmann
0 siblings, 2 replies; 20+ messages in thread
From: Thomas Rodgers @ 2020-10-07 16:55 UTC (permalink / raw)
To: gcc-patches, libstdc++; +Cc: trodgers
From: Thomas Rodgers <trodgers@redhat.com>
New ctors and ::view() accessor for -
* basic_stingbuf
* basic_istringstream
* basic_ostringstream
* basic_stringstreamm
New ::get_allocator() accessor for basic_stringbuf.
libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
* config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
basic_stringbuf::basic_stringbuf(allocator const&),
basic_stringbuf::basic_stringbuf(openmode, allocator const&),
basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
basic_stringbuf::get_allocator(),
basic_stringbuf::view(),
basic_istringstream::basic_istringstream(basic_string&&, openmode),
basic_istringstream::basic_istringstream(openmode, allocator const&),
basic_istringstream::view(),
basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
basic_ostringstream::basic_ostringstream(openmode, allocator const&),
basic_ostringstream::view(),
basic_stringstream::basic_stringstream(basic_string&&, openmode),
basic_stringstream::basic_stringstream(openmode, allocator const&),
basic_stringstream::view().
* configure: Regenerate.
* include/std/sstream:
(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
(basic_stringbuf::get_allocator()): New method.
(basic_stringbuf::view()): Likewise.
(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
New constructor.
(basic_istringstream::basic_istringstream(openmode, allocator const&)):
Likewise
(basic_istringstream::view()): New method.
(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
New constructor.
(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
Likewise
(basic_ostringstream::view()): New method.
(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
New constructor.
(basic_stringstream::basic_stringstream(openmode, allocator const&)):
Likewise
(basic_stringstream::view()): New method.
* src/Makefile.in: Add c++20 directory.
* src/Makefile.am: Regenerate.
* src/c++20/Makefile.am: Add makefile for new sub-directory.
* src/c++20/Makefile.in: Generate.
* src/c++20/sstream-inst.cc: New file defining explicit
instantiations for basic_stringbuf, basic_istringstream,
basic_ostringstream, and basic_stringstream member functions
added in C++20.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
---
.topdeps | 1 +
.topmsg | 2 +
libstdc++-v3/acinclude.m4 | 2 +-
libstdc++-v3/config/abi/pre/gnu.ver | 60 ++
libstdc++-v3/configure | 16 +-
libstdc++-v3/include/std/sstream | 198 +++++
libstdc++-v3/src/Makefile.am | 12 +-
libstdc++-v3/src/Makefile.in | 14 +-
libstdc++-v3/src/c++20/Makefile.am | 105 +++
libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
libstdc++-v3/src/c++20/sstream-inst.cc | 110 +++
.../27_io/basic_istringstream/cons/char/1.cc | 84 ++
.../basic_istringstream/cons/wchar_t/1.cc | 84 ++
.../27_io/basic_istringstream/view/char/1.cc | 34 +
.../basic_istringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_ostringstream/cons/char/1.cc | 84 ++
.../basic_ostringstream/cons/wchar_t/1.cc | 84 ++
.../27_io/basic_ostringstream/view/char/1.cc | 34 +
.../basic_ostringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringbuf/cons/char/2.cc | 120 +++
.../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++
.../27_io/basic_stringbuf/view/char/1.cc | 34 +
.../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringstream/cons/char/1.cc | 84 ++
.../basic_stringstream/cons/wchar_t/1.cc | 84 ++
.../27_io/basic_stringstream/view/char/1.cc | 34 +
.../basic_stringstream/view/wchar_t/1.cc | 35 +
27 files changed, 2248 insertions(+), 12 deletions(-)
create mode 100644 .topdeps
create mode 100644 .topmsg
create mode 100644 libstdc++-v3/src/c++20/Makefile.am
create mode 100644 libstdc++-v3/src/c++20/Makefile.in
create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
diff --git a/.topdeps b/.topdeps
new file mode 100644
index 00000000000..1f7391f92b6
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+master
diff --git a/.topmsg b/.topmsg
new file mode 100644
index 00000000000..0c035ed2f0c
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,2 @@
+From: Thomas Rodgers <trodgers@redhat.com>
+Subject: [PATCH] t/trodgers/c2a_sstream
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 133125ec4fa..b9452dd74cd 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 87a48a21f53..3239bb1a53d 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2322,6 +2322,66 @@ GLIBCXX_3.4.29 {
# std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady
_ZNSt28__atomic_futex_unsigned_base26_M_futex_wait_until_steady*;
+ # basic_stringbuf::basic_stringbuf(allocator const&)
+ _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ERKS3_;
+ _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ERKS3_;
+
+ # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3;
+ _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3;
+
+ # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode;
+ _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1EOS4_RKS3_;
+ _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1EOS4_RKS3_;
+
+ # basic_stringbuf::get_allocator()
+ _ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv;
+ _ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv;
+
+ # basic_stringbuf::view()
+ _ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE4viewEv;
+ _ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE4viewEv;
+
+ # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode;
+ _ZNSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode;
+
+ # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+ _ZNSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_istringstream::view()
+ _ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE4viewEv;
+ _ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE4viewEv;
+
+ # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode;
+ _ZNSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode;
+
+ # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+ _ZNSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_ostringstream::view()
+ _ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE4viewEv;
+ _ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE4viewEv;
+
+ # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode;
+ _ZNSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+ _ZNSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_stringstream::view()
+ _ZNKSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEE4viewEv;
+ _ZNKSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEE4viewEv;
+
} GLIBCXX_3.4.28;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 7abf1b1ccc1..eecf63f4a59 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -5418,7 +5418,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; }
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
- SUBDIRS='include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python'
+ SUBDIRS='include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python'
# These need to be absolute paths, yet at the same time need to
# canonicalize only relative paths, because then amd will not unmount
@@ -78394,7 +78394,7 @@ ac_config_files="$ac_config_files doc/xsl/customization.xsl"
# append it here. Only modify Makefiles that have just been created.
#
# Also, get rid of this simulated-VPATH thing that automake does.
-ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile src/c++17/Makefile src/filesystem/Makefile doc/Makefile po/Makefile testsuite/Makefile python/Makefile"
+ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile src/c++17/Makefile src/c++20/Makefile src/filesystem/Makefile doc/Makefile po/Makefile testsuite/Makefile python/Makefile"
ac_config_commands="$ac_config_commands generate-headers"
@@ -79650,6 +79650,7 @@ do
"src/c++98/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++98/Makefile" ;;
"src/c++11/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++11/Makefile" ;;
"src/c++17/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++17/Makefile" ;;
+ "src/c++20/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++20/Makefile" ;;
"src/filesystem/Makefile") CONFIG_FILES="$CONFIG_FILES src/filesystem/Makefile" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;;
@@ -81500,6 +81501,17 @@ _EOF
;;
"src/c++17/Makefile":F) cat > vpsed$$ << \_EOF
s!`test -f '$<' || echo '$(srcdir)/'`!!
+_EOF
+ sed -f vpsed$$ $ac_file > tmp$$
+ mv tmp$$ $ac_file
+ rm vpsed$$
+ echo 'MULTISUBDIR =' >> $ac_file
+ ml_norecursion=yes
+ . ${multi_basedir}/config-ml.in
+ { ml_norecursion=; unset ml_norecursion;}
+ ;;
+ "src/c++20/Makefile":F) cat > vpsed$$ << \_EOF
+s!`test -f '$<' || echo '$(srcdir)/'`!!
_EOF
sed -f vpsed$$ $ac_file > tmp$$
mv tmp$$ $ac_file
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 9cca54d17d1..fb0fb9f8beb 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -165,6 +165,56 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L
+ basic_stringbuf(const allocator_type& __a)
+ : basic_stringbuf(ios_base::in | std::ios_base::out, __a)
+ { }
+
+ basic_stringbuf(ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode), _M_string(__a)
+ { }
+
+ explicit
+ basic_stringbuf(__string_type&& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out )
+ : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
+ { }
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ const allocator_type& __a )
+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a )
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode),
+ _M_string(static_cast<__sv_type>(__s), __a)
+ { }
+
+ template<typename _SAlloc>
+ explicit
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringbuf(__s, __mode, allocator_type{})
+ { }
+
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
+ : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this))
+ { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); }
+
+ allocator_type get_allocator() const noexcept
+ { return _M_string.get_allocator(); }
+
+#endif
+
// Get and set:
/**
* @brief Copying out the string buffer.
@@ -207,6 +257,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_stringbuf_init(_M_mode);
}
+#if __cplusplus > 201703L
+ __sv_type
+ view() const noexcept
+ {
+ if (this->pptr())
+ {
+ // The current egptr() may not be the actual string end.
+ if (this->pptr() > this->egptr())
+ return __sv_type(this->pbase(), this->pptr());
+ else
+ return __sv_type(this->pbase(), this->egptr());
+ }
+ else
+ return static_cast<__sv_type>(_M_string);
+ }
+
+#endif
+
protected:
// Common initialization code goes here.
void
@@ -369,6 +437,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
: __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
_M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
{ }
+
+#if __cplusplus > 201703L
+ // The move constructor initializes an __xfer_bufptrs temporary then
+ // delegates to this constructor to performs moves during its lifetime.
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a,
+ __xfer_bufptrs&&)
+ : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
+ _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a)
+ { }
+#endif
#endif
};
@@ -500,6 +578,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L
+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_istringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::in )
+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_istringstream(__str, ios_base::in, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __istream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in)
+ : basic_istringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -528,6 +640,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -658,6 +776,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L
+ basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_ostringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out )
+ : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_ostringstream(__str, ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __ostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::out)
+ : basic_ostringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -686,6 +838,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -812,6 +970,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L
+ basic_stringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(), _M_stringbuf(__mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_stringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out
+ | ios_base::out)
+ : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_stringstream(__str, ios_base::in | ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -840,6 +1032,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
#if __cplusplus >= 201103L
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index a139adc81b3..9a6807ae8c6 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -29,7 +29,7 @@ filesystem_dir =
endif
## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
-SUBDIRS = c++98 c++11 c++17 $(filesystem_dir)
+SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
# Cross compiler support.
if VTV_CYGMIN
@@ -60,6 +60,7 @@ endif
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
vpath % $(top_srcdir)/src/c++17
+vpath % $(top_srcdir)/src/c++20
if ENABLE_FILESYSTEM_TS
vpath % $(top_srcdir)/src/filesystem
endif
@@ -95,14 +96,16 @@ libstdc___la_LIBADD = \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_DEPENDENCIES = \
${version_dep} \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_LDFLAGS = \
-version-info $(libtool_VERSION) ${version_arg} -lm
@@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc
# segregated in the sources with -D_GLIBCXX_SHARED.
#
# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
-# only -prefer-pic objects are generated for the convenience libraries.
+# src/c++20, only -prefer-pic objects are generated for the convenience
+# libraries.
#
# In the main src directory, make shared and static objects just for
# the compat libraries. Shared objects are compiled with -prefer-pic
diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am
new file mode 100644
index 00000000000..423a79f3686
--- /dev/null
+++ b/libstdc++-v3/src/c++20/Makefile.am
@@ -0,0 +1,105 @@
+## Makefile for the C++20 sources of the GNU C++ Standard library.
+##
+## Copyright (C) 1997-2020 Free Software Foundation, Inc.
+##
+## This file is part of the libstdc++ version 3 distribution.
+## Process this file with automake to produce Makefile.in.
+
+## This file is part of the GNU ISO C++ Library. This library is free
+## software; you can redistribute it and/or modify it under the
+## terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 3, or (at your option)
+## any later version.
+
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License along
+## with this library; see the file COPYING3. If not see
+## <http://www.gnu.org/licenses/>.
+
+include $(top_srcdir)/fragment.am
+
+# Convenience library for C++17 runtime.
+noinst_LTLIBRARIES = libc++20convenience.la
+
+headers =
+
+if ENABLE_EXTERN_TEMPLATE
+# XTEMPLATE_FLAGS = -fno-implicit-templates
+inst_sources = \
+ sstream-inst.cc
+else
+# XTEMPLATE_FLAGS =
+inst_sources =
+endif
+
+sources =
+
+vpath % $(top_srcdir)/src/c++20
+
+libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
+
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way. Need to manually
+# set this option because CONFIG_CXXFLAGS has to be after
+# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+# as the occasion calls for it.
+AM_CXXFLAGS = \
+ -std=gnu++20 \
+ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
+ -fimplicit-templates
+
+AM_MAKEFLAGS = \
+ "gxx_include_dir=$(gxx_include_dir)"
+
+# Libtool notes
+
+# 1) In general, libtool expects an argument such as `--tag=CXX' when
+# using the C++ compiler, because that will enable the settings
+# detected when C++ support was being configured. However, when no
+# such flag is given in the command line, libtool attempts to figure
+# it out by matching the compiler name in each configuration section
+# against a prefix of the command line. The problem is that, if the
+# compiler name and its initial flags stored in the libtool
+# configuration file don't match those in the command line, libtool
+# can't decide which configuration to use, and it gives up. The
+# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
+# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
+# attempt to infer which configuration to use.
+#
+# The second tag argument, `--tag disable-shared` means that libtool
+# only compiles each source once, for static objects. In actuality,
+# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
+# the libtool command that is used create the object, which is
+# suitable for shared libraries. The `--tag disable-shared` must be
+# placed after --tag CXX lest things CXX undo the affect of
+# disable-shared.
+
+# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
+# last. (That way, things like -O2 passed down from the toplevel can
+# be overridden by --enable-debug.)
+LTCXXCOMPILE = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
+
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
+
+# 3) We'd have a problem when building the shared libstdc++ object if
+# the rules automake generates would be used. We cannot allow g++ to
+# be used since this would add -lstdc++ to the link line which of
+# course is problematic at this point. So, we get the top-level
+# directory to configure libstdc++-v3 to use gcc as the C++
+# compilation driver.
+CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+ $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
new file mode 100644
index 00000000000..0e2de19ae59
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
new file mode 100644
index 00000000000..c7fa065bf18
--- /dev/null
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -0,0 +1,110 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<char>::allocator_type
+ basic_stringbuf<char>::get_allocator() const noexcept;
+template basic_stringbuf<char>::__sv_type
+ basic_stringbuf<char>::view() const noexcept;
+
+
+template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<char>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<char>::__sv_type
+ basic_istringstream<char>::view() const noexcept;
+
+template basic_ostringstream<char>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<char>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<char>::__sv_type
+ basic_ostringstream<char>::view() const noexcept;
+
+template basic_stringstream<char>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<char>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<char>::__sv_type
+ basic_stringstream<char>::view() const noexcept;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::allocator_type
+ basic_stringbuf<wchar_t>::get_allocator() const noexcept;
+template basic_stringbuf<wchar_t>::__sv_type
+ basic_stringbuf<wchar_t>::view() const noexcept;
+
+template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<wchar_t>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<wchar_t>::__sv_type
+ basic_istringstream<wchar_t>::view() const noexcept;
+
+template basic_ostringstream<wchar_t>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<wchar_t>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<wchar_t>::__sv_type
+ basic_ostringstream<wchar_t>::view() const noexcept;
+
+template basic_stringstream<wchar_t>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<wchar_t>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<wchar_t>::__sv_type
+ basic_stringstream<wchar_t>::view() const noexcept;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
new file mode 100644
index 00000000000..c902e55c4f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::istringstream::allocator_type a;
+ std::istringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::istringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::istringstream::allocator_type a;
+ std::istringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..db1e3ff1728
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
new file mode 100644
index 00000000000..6859fec2ce9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::istringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..3c447bb23e9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wistringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
new file mode 100644
index 00000000000..f7f71e0aa99
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::ostringstream::allocator_type a;
+ std::ostringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::ostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::ostringstream::allocator_type a;
+ std::ostringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..10c28fe5880
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wostringstream::allocator_type a;
+ std::wostringstream stm(std::ios_base::out, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wostringstream::allocator_type a;
+ std::wostringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
new file mode 100644
index 00000000000..d080e3c7771
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::ostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..8cb51a30e24
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
new file mode 100644
index 00000000000..e611a2fcfce
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
@@ -0,0 +1,120 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ {
+ using alloc_type = __gnu_test::uneq_allocator<char>;
+ using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
+ alloc_type>;
+
+ alloc_type aa;
+ sbuf_t sbuf1(aa);
+ VERIFY( aa == sbuf1.get_allocator() );
+
+ alloc_type aaa(42);
+ sbuf_t sbuf2(aaa);
+ VERIFY( aaa == sbuf2.get_allocator() );
+
+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
+ }
+
+ std::stringbuf::allocator_type a;
+ {
+ std::stringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::stringbuf sbuf(a);
+ }
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::stringbuf sbuf1(cstr);
+
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::string s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
new file mode 100644
index 00000000000..d2c435b2f10
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
@@ -0,0 +1,105 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wstringbuf::allocator_type a;
+ {
+ std::wstringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::wstringbuf sbuf(a);
+ }
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wstringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::wstringbuf sbuf1(cstr);
+
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::wstring s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
new file mode 100644
index 00000000000..40af4b094cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
new file mode 100644
index 00000000000..ffa27996803
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
new file mode 100644
index 00000000000..021341342be
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stringstream::allocator_type a;
+ std::stringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringstream::allocator_type a;
+ std::stringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..db1e3ff1728
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
new file mode 100644
index 00000000000..c596b5872ed
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..a5f251969c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-07 16:55 [PATCH] libstdc++: Implement C++20 features for <sstream> Thomas Rodgers
@ 2020-10-07 19:44 ` Jonathan Wakely
2020-10-07 21:53 ` Thomas Rodgers
2020-10-08 1:15 ` Thomas Rodgers
2020-11-04 19:54 ` Stephan Bergmann
1 sibling, 2 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-07 19:44 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, trodgers
On 07/10/20 09:55 -0700, Thomas Rodgers wrote:
>From: Thomas Rodgers <trodgers@redhat.com>
>
>New ctors and ::view() accessor for -
> * basic_stingbuf
> * basic_istringstream
> * basic_ostringstream
> * basic_stringstreamm
>
>New ::get_allocator() accessor for basic_stringbuf.
>
>libstdc++-v3/ChangeLog:
> * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
> * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
> basic_stringbuf::basic_stringbuf(allocator const&),
> basic_stringbuf::basic_stringbuf(openmode, allocator const&),
> basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
> basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
> basic_stringbuf::get_allocator(),
> basic_stringbuf::view(),
> basic_istringstream::basic_istringstream(basic_string&&, openmode),
> basic_istringstream::basic_istringstream(openmode, allocator const&),
> basic_istringstream::view(),
> basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
> basic_ostringstream::basic_ostringstream(openmode, allocator const&),
> basic_ostringstream::view(),
> basic_stringstream::basic_stringstream(basic_string&&, openmode),
> basic_stringstream::basic_stringstream(openmode, allocator const&),
> basic_stringstream::view().
> * configure: Regenerate.
> * include/std/sstream:
> (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
> (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
> (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
> (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
> (basic_stringbuf::get_allocator()): New method.
> (basic_stringbuf::view()): Likewise.
> (basic_istringstream::basic_istringstream(basic_string&&, openmode)):
> New constructor.
> (basic_istringstream::basic_istringstream(openmode, allocator const&)):
> Likewise
> (basic_istringstream::view()): New method.
> (basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
> New constructor.
> (basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
> Likewise
> (basic_ostringstream::view()): New method.
> (basic_stringstream::basic_stringstream(basic_string&&, openmode)):
> New constructor.
> (basic_stringstream::basic_stringstream(openmode, allocator const&)):
> Likewise
> (basic_stringstream::view()): New method.
> * src/Makefile.in: Add c++20 directory.
> * src/Makefile.am: Regenerate.
> * src/c++20/Makefile.am: Add makefile for new sub-directory.
> * src/c++20/Makefile.in: Generate.
> * src/c++20/sstream-inst.cc: New file defining explicit
> instantiations for basic_stringbuf, basic_istringstream,
> basic_ostringstream, and basic_stringstream member functions
> added in C++20.
> * testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
> * testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
>---
> .topdeps | 1 +
> .topmsg | 2 +
> libstdc++-v3/acinclude.m4 | 2 +-
> libstdc++-v3/config/abi/pre/gnu.ver | 60 ++
> libstdc++-v3/configure | 16 +-
> libstdc++-v3/include/std/sstream | 198 +++++
> libstdc++-v3/src/Makefile.am | 12 +-
> libstdc++-v3/src/Makefile.in | 14 +-
> libstdc++-v3/src/c++20/Makefile.am | 105 +++
> libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
> libstdc++-v3/src/c++20/sstream-inst.cc | 110 +++
> .../27_io/basic_istringstream/cons/char/1.cc | 84 ++
> .../basic_istringstream/cons/wchar_t/1.cc | 84 ++
> .../27_io/basic_istringstream/view/char/1.cc | 34 +
> .../basic_istringstream/view/wchar_t/1.cc | 35 +
> .../27_io/basic_ostringstream/cons/char/1.cc | 84 ++
> .../basic_ostringstream/cons/wchar_t/1.cc | 84 ++
> .../27_io/basic_ostringstream/view/char/1.cc | 34 +
> .../basic_ostringstream/view/wchar_t/1.cc | 35 +
> .../27_io/basic_stringbuf/cons/char/2.cc | 120 +++
> .../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++
> .../27_io/basic_stringbuf/view/char/1.cc | 34 +
> .../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 +
> .../27_io/basic_stringstream/cons/char/1.cc | 84 ++
> .../basic_stringstream/cons/wchar_t/1.cc | 84 ++
> .../27_io/basic_stringstream/view/char/1.cc | 34 +
> .../basic_stringstream/view/wchar_t/1.cc | 35 +
> 27 files changed, 2248 insertions(+), 12 deletions(-)
> create mode 100644 .topdeps
> create mode 100644 .topmsg
> create mode 100644 libstdc++-v3/src/c++20/Makefile.am
> create mode 100644 libstdc++-v3/src/c++20/Makefile.in
> create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
>
>diff --git a/.topdeps b/.topdeps
>new file mode 100644
>index 00000000000..1f7391f92b6
>--- /dev/null
>+++ b/.topdeps
>@@ -0,0 +1 @@
>+master
>diff --git a/.topmsg b/.topmsg
>new file mode 100644
>index 00000000000..0c035ed2f0c
>--- /dev/null
>+++ b/.topmsg
>@@ -0,0 +1,2 @@
>+From: Thomas Rodgers <trodgers@redhat.com>
>+Subject: [PATCH] t/trodgers/c2a_sstream
>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>index 133125ec4fa..b9452dd74cd 100644
>--- a/libstdc++-v3/acinclude.m4
>+++ b/libstdc++-v3/acinclude.m4
>@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
> # Keep these sync'd with the list in Makefile.am. The first provides an
> # expandable list at autoconf time; the second provides an expandable list
> # (i.e., shell variable) at configure time.
>- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
>+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
> SUBDIRS='glibcxx_SUBDIRS'
>
> # These need to be absolute paths, yet at the same time need to
>diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
>index 87a48a21f53..3239bb1a53d 100644
>--- a/libstdc++-v3/config/abi/pre/gnu.ver
>+++ b/libstdc++-v3/config/abi/pre/gnu.ver
>@@ -2322,6 +2322,66 @@ GLIBCXX_3.4.29 {
> # std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady
> _ZNSt28__atomic_futex_unsigned_base26_M_futex_wait_until_steady*;
>
>+ # basic_stringbuf::basic_stringbuf(allocator const&)
>+ _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ERKS3_;
>+ _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ERKS3_;
Please combine these symbols by using [cw] wherever the char_type
appears e.g.
# basic_stringbuf::basic_stringbuf(allocator const&)
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
>diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
>index 7abf1b1ccc1..eecf63f4a59 100755
>--- a/libstdc++-v3/configure
>+++ b/libstdc++-v3/configure
This is a generated file so can be filtered out of the patch.
>diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
>new file mode 100644
>index 00000000000..c7fa065bf18
>--- /dev/null
>+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
>@@ -0,0 +1,110 @@
>+// Explicit instantiation file.
>+
>+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// Under Section 7 of GPL version 3, you are granted additional
>+// permissions described in the GCC Runtime Library Exception, version
>+// 3.1, as published by the Free Software Foundation.
>+
>+// You should have received a copy of the GNU General Public License and
>+// a copy of the GCC Runtime Library Exception along with this program;
>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>+// <http://www.gnu.org/licenses/>.
>+
>+//
>+// ISO C++ 14882:
>+//
>+
>+#ifndef _GLIBCXX_USE_CXX11_ABI
>+// Instantiations in this file use the new SSO std::string ABI unless included
>+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
>+# define _GLIBCXX_USE_CXX11_ABI 1
>+#endif
Nothing includes this with _GLIBCXX_USE_CXX11_ABI=0 defined. That
means all the tests will fail if run with that defined, e.g.
make check RUNTESTFLAGS="conformance.exp=27_io/*string* --target_board=unix/-D_GLIBCXX_USE_CXX11_ABI=0"
Either you need to add a src/c++20/cow-sstream-inst.cc file that does:
#define _GLIBCXX_USE_CXX11_ABI 0
#include "sstream-inst.cc"
and then export all the resulting symbols, or the new features should
only be defined for the new ABI, i.e. instead of
#if __cplusplus > 201703L
they should be guarded by
#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
I'm not sure how feasible it is to make the new features work with the
old ABI, as the old std::string doesn't propagate allocators properly.
It might just work with no extra effort needed though.
If it doesn't work, and the features are disabled for the old ABI,
then all the new tests need:
// { dg-require-effective-target cxx11-abi }
so that they are skipped as UNSUPPORTED when run with
_GLIBCXX_USE_CXX11_ABI=0 defined.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-07 19:44 ` Jonathan Wakely
@ 2020-10-07 21:53 ` Thomas Rodgers
2020-10-08 1:15 ` Thomas Rodgers
1 sibling, 0 replies; 20+ messages in thread
From: Thomas Rodgers @ 2020-10-07 21:53 UTC (permalink / raw)
To: gcc-patches, libstdc++; +Cc: trodgers
From: Thomas Rodgers <trodgers@redhat.com>
New ctors and ::view() accessor for -
* basic_stingbuf
* basic_istringstream
* basic_ostringstream
* basic_stringstreamm
New ::get_allocator() accessor for basic_stringbuf.
libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
* config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
basic_stringbuf::basic_stringbuf(allocator const&),
basic_stringbuf::basic_stringbuf(openmode, allocator const&),
basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
basic_stringbuf::get_allocator(),
basic_stringbuf::view(),
basic_istringstream::basic_istringstream(basic_string&&, openmode),
basic_istringstream::basic_istringstream(openmode, allocator const&),
basic_istringstream::view(),
basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
basic_ostringstream::basic_ostringstream(openmode, allocator const&),
basic_ostringstream::view(),
basic_stringstream::basic_stringstream(basic_string&&, openmode),
basic_stringstream::basic_stringstream(openmode, allocator const&),
basic_stringstream::view().
* configure: Regenerate.
* include/std/sstream:
(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
(basic_stringbuf::get_allocator()): New method.
(basic_stringbuf::view()): Likewise.
(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
New constructor.
(basic_istringstream::basic_istringstream(openmode, allocator const&)):
Likewise
(basic_istringstream::view()): New method.
(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
New constructor.
(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
Likewise
(basic_ostringstream::view()): New method.
(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
New constructor.
(basic_stringstream::basic_stringstream(openmode, allocator const&)):
Likewise
(basic_stringstream::view()): New method.
* src/Makefile.in: Add c++20 directory.
* src/Makefile.am: Regenerate.
* src/c++20/Makefile.am: Add makefile for new sub-directory.
* src/c++20/Makefile.in: Generate.
* src/c++20/sstream-inst.cc: New file defining explicit
instantiations for basic_stringbuf, basic_istringstream,
basic_ostringstream, and basic_stringstream member functions
added in C++20.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
---
.topdeps | 1 +
.topmsg | 2 +
libstdc++-v3/acinclude.m4 | 2 +-
libstdc++-v3/config/abi/pre/gnu.ver | 45 ++
libstdc++-v3/configure | 16 +-
libstdc++-v3/include/std/sstream | 196 +++++
libstdc++-v3/src/Makefile.am | 12 +-
libstdc++-v3/src/Makefile.in | 14 +-
libstdc++-v3/src/c++20/Makefile.am | 105 +++
libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
libstdc++-v3/src/c++20/sstream-inst.cc | 110 +++
.../27_io/basic_istringstream/cons/char/1.cc | 85 ++
.../basic_istringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_istringstream/view/char/1.cc | 35 +
.../basic_istringstream/view/wchar_t/1.cc | 36 +
.../27_io/basic_ostringstream/cons/char/1.cc | 85 ++
.../basic_ostringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_ostringstream/view/char/1.cc | 35 +
.../basic_ostringstream/view/wchar_t/1.cc | 36 +
.../27_io/basic_stringbuf/cons/char/2.cc | 121 +++
.../27_io/basic_stringbuf/cons/wchar_t/2.cc | 106 +++
.../27_io/basic_stringbuf/view/char/1.cc | 35 +
.../27_io/basic_stringbuf/view/wchar_t/1.cc | 36 +
.../27_io/basic_stringstream/cons/char/1.cc | 85 ++
.../basic_stringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_stringstream/view/char/1.cc | 35 +
.../basic_stringstream/view/wchar_t/1.cc | 36 +
27 files changed, 2247 insertions(+), 12 deletions(-)
create mode 100644 .topdeps
create mode 100644 .topmsg
create mode 100644 libstdc++-v3/src/c++20/Makefile.am
create mode 100644 libstdc++-v3/src/c++20/Makefile.in
create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
diff --git a/.topdeps b/.topdeps
new file mode 100644
index 00000000000..1f7391f92b6
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+master
diff --git a/.topmsg b/.topmsg
new file mode 100644
index 00000000000..0c035ed2f0c
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,2 @@
+From: Thomas Rodgers <trodgers@redhat.com>
+Subject: [PATCH] t/trodgers/c2a_sstream
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 133125ec4fa..b9452dd74cd 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 87a48a21f53..c57765ebac3 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2322,6 +2322,51 @@ GLIBCXX_3.4.29 {
# std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady
_ZNSt28__atomic_futex_unsigned_base26_M_futex_wait_until_steady*;
+ # basic_stringbuf::basic_stringbuf(allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
+
+ # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
+
+ # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
+
+ # basic_stringbuf::get_allocator()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
+
+ # basic_stringbuf::view()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_istringstream::view()
+ _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_ostringstream::view()
+ _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_stringstream::view()
+ _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
} GLIBCXX_3.4.28;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 9cca54d17d1..09a572881c2 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -165,6 +165,55 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_stringbuf(const allocator_type& __a)
+ : basic_stringbuf(ios_base::in | std::ios_base::out, __a)
+ { }
+
+ basic_stringbuf(ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode), _M_string(__a)
+ { }
+
+ explicit
+ basic_stringbuf(__string_type&& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out )
+ : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
+ { }
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ const allocator_type& __a )
+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a )
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode),
+ _M_string(static_cast<__sv_type>(__s), __a)
+ { }
+
+ template<typename _SAlloc>
+ explicit
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringbuf(__s, __mode, allocator_type{})
+ { }
+
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
+ : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this))
+ { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); }
+
+ allocator_type get_allocator() const noexcept
+ { return _M_string.get_allocator(); }
+#endif
+
// Get and set:
/**
* @brief Copying out the string buffer.
@@ -207,6 +256,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_stringbuf_init(_M_mode);
}
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ {
+ if (this->pptr())
+ {
+ // The current egptr() may not be the actual string end.
+ if (this->pptr() > this->egptr())
+ return __sv_type(this->pbase(), this->pptr());
+ else
+ return __sv_type(this->pbase(), this->egptr());
+ }
+ else
+ return static_cast<__sv_type>(_M_string);
+ }
+#endif
+
protected:
// Common initialization code goes here.
void
@@ -369,6 +435,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
: __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
_M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
{ }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ // The move constructor initializes an __xfer_bufptrs temporary then
+ // delegates to this constructor to performs moves during its lifetime.
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a,
+ __xfer_bufptrs&&)
+ : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
+ _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a)
+ { }
+#endif
#endif
};
@@ -500,6 +576,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_istringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::in )
+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_istringstream(__str, ios_base::in, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __istream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in)
+ : basic_istringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -528,6 +638,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -658,6 +774,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_ostringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out )
+ : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_ostringstream(__str, ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __ostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::out)
+ : basic_ostringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -686,6 +836,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -812,6 +968,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_stringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(), _M_stringbuf(__mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_stringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out
+ | ios_base::out)
+ : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_stringstream(__str, ios_base::in | ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -840,6 +1030,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
#if __cplusplus >= 201103L
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index a139adc81b3..9a6807ae8c6 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -29,7 +29,7 @@ filesystem_dir =
endif
## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
-SUBDIRS = c++98 c++11 c++17 $(filesystem_dir)
+SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
# Cross compiler support.
if VTV_CYGMIN
@@ -60,6 +60,7 @@ endif
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
vpath % $(top_srcdir)/src/c++17
+vpath % $(top_srcdir)/src/c++20
if ENABLE_FILESYSTEM_TS
vpath % $(top_srcdir)/src/filesystem
endif
@@ -95,14 +96,16 @@ libstdc___la_LIBADD = \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_DEPENDENCIES = \
${version_dep} \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_LDFLAGS = \
-version-info $(libtool_VERSION) ${version_arg} -lm
@@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc
# segregated in the sources with -D_GLIBCXX_SHARED.
#
# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
-# only -prefer-pic objects are generated for the convenience libraries.
+# src/c++20, only -prefer-pic objects are generated for the convenience
+# libraries.
#
# In the main src directory, make shared and static objects just for
# the compat libraries. Shared objects are compiled with -prefer-pic
diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am
new file mode 100644
index 00000000000..423a79f3686
--- /dev/null
+++ b/libstdc++-v3/src/c++20/Makefile.am
@@ -0,0 +1,105 @@
+## Makefile for the C++20 sources of the GNU C++ Standard library.
+##
+## Copyright (C) 1997-2020 Free Software Foundation, Inc.
+##
+## This file is part of the libstdc++ version 3 distribution.
+## Process this file with automake to produce Makefile.in.
+
+## This file is part of the GNU ISO C++ Library. This library is free
+## software; you can redistribute it and/or modify it under the
+## terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 3, or (at your option)
+## any later version.
+
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License along
+## with this library; see the file COPYING3. If not see
+## <http://www.gnu.org/licenses/>.
+
+include $(top_srcdir)/fragment.am
+
+# Convenience library for C++17 runtime.
+noinst_LTLIBRARIES = libc++20convenience.la
+
+headers =
+
+if ENABLE_EXTERN_TEMPLATE
+# XTEMPLATE_FLAGS = -fno-implicit-templates
+inst_sources = \
+ sstream-inst.cc
+else
+# XTEMPLATE_FLAGS =
+inst_sources =
+endif
+
+sources =
+
+vpath % $(top_srcdir)/src/c++20
+
+libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
+
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way. Need to manually
+# set this option because CONFIG_CXXFLAGS has to be after
+# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+# as the occasion calls for it.
+AM_CXXFLAGS = \
+ -std=gnu++20 \
+ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
+ -fimplicit-templates
+
+AM_MAKEFLAGS = \
+ "gxx_include_dir=$(gxx_include_dir)"
+
+# Libtool notes
+
+# 1) In general, libtool expects an argument such as `--tag=CXX' when
+# using the C++ compiler, because that will enable the settings
+# detected when C++ support was being configured. However, when no
+# such flag is given in the command line, libtool attempts to figure
+# it out by matching the compiler name in each configuration section
+# against a prefix of the command line. The problem is that, if the
+# compiler name and its initial flags stored in the libtool
+# configuration file don't match those in the command line, libtool
+# can't decide which configuration to use, and it gives up. The
+# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
+# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
+# attempt to infer which configuration to use.
+#
+# The second tag argument, `--tag disable-shared` means that libtool
+# only compiles each source once, for static objects. In actuality,
+# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
+# the libtool command that is used create the object, which is
+# suitable for shared libraries. The `--tag disable-shared` must be
+# placed after --tag CXX lest things CXX undo the affect of
+# disable-shared.
+
+# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
+# last. (That way, things like -O2 passed down from the toplevel can
+# be overridden by --enable-debug.)
+LTCXXCOMPILE = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
+
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
+
+# 3) We'd have a problem when building the shared libstdc++ object if
+# the rules automake generates would be used. We cannot allow g++ to
+# be used since this would add -lstdc++ to the link line which of
+# course is problematic at this point. So, we get the top-level
+# directory to configure libstdc++-v3 to use gcc as the C++
+# compilation driver.
+CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+ $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
new file mode 100644
index 00000000000..0e2de19ae59
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
new file mode 100644
index 00000000000..c7fa065bf18
--- /dev/null
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -0,0 +1,110 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<char>::allocator_type
+ basic_stringbuf<char>::get_allocator() const noexcept;
+template basic_stringbuf<char>::__sv_type
+ basic_stringbuf<char>::view() const noexcept;
+
+
+template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<char>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<char>::__sv_type
+ basic_istringstream<char>::view() const noexcept;
+
+template basic_ostringstream<char>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<char>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<char>::__sv_type
+ basic_ostringstream<char>::view() const noexcept;
+
+template basic_stringstream<char>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<char>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<char>::__sv_type
+ basic_stringstream<char>::view() const noexcept;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::allocator_type
+ basic_stringbuf<wchar_t>::get_allocator() const noexcept;
+template basic_stringbuf<wchar_t>::__sv_type
+ basic_stringbuf<wchar_t>::view() const noexcept;
+
+template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<wchar_t>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<wchar_t>::__sv_type
+ basic_istringstream<wchar_t>::view() const noexcept;
+
+template basic_ostringstream<wchar_t>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<wchar_t>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<wchar_t>::__sv_type
+ basic_ostringstream<wchar_t>::view() const noexcept;
+
+template basic_stringstream<wchar_t>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<wchar_t>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<wchar_t>::__sv_type
+ basic_stringstream<wchar_t>::view() const noexcept;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
new file mode 100644
index 00000000000..d93141fc232
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::istringstream::allocator_type a;
+ std::istringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::istringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::istringstream::allocator_type a;
+ std::istringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..f89402fd24e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
new file mode 100644
index 00000000000..091de5f7a79
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::istringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..36c3cd033ac
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
@@ -0,0 +1,36 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wistringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
new file mode 100644
index 00000000000..bfc026de65e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::ostringstream::allocator_type a;
+ std::ostringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::ostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::ostringstream::allocator_type a;
+ std::ostringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..07b2613cbbb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wostringstream::allocator_type a;
+ std::wostringstream stm(std::ios_base::out, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wostringstream::allocator_type a;
+ std::wostringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
new file mode 100644
index 00000000000..a366363abb5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::ostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..76712ac02e4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
@@ -0,0 +1,36 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
new file mode 100644
index 00000000000..c64c9d0296a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
@@ -0,0 +1,121 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ {
+ using alloc_type = __gnu_test::uneq_allocator<char>;
+ using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
+ alloc_type>;
+
+ alloc_type aa;
+ sbuf_t sbuf1(aa);
+ VERIFY( aa == sbuf1.get_allocator() );
+
+ alloc_type aaa(42);
+ sbuf_t sbuf2(aaa);
+ VERIFY( aaa == sbuf2.get_allocator() );
+
+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
+ }
+
+ std::stringbuf::allocator_type a;
+ {
+ std::stringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::stringbuf sbuf(a);
+ }
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::stringbuf sbuf1(cstr);
+
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::string s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
new file mode 100644
index 00000000000..341d6aa542e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
@@ -0,0 +1,106 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wstringbuf::allocator_type a;
+ {
+ std::wstringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::wstringbuf sbuf(a);
+ }
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wstringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::wstringbuf sbuf1(cstr);
+
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::wstring s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
new file mode 100644
index 00000000000..8f8c62daa21
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
new file mode 100644
index 00000000000..b079a469547
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
@@ -0,0 +1,36 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
new file mode 100644
index 00000000000..accb1d3b4ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stringstream::allocator_type a;
+ std::stringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringstream::allocator_type a;
+ std::stringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..f89402fd24e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
new file mode 100644
index 00000000000..f47035cf148
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..e7b7ac17e09
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
@@ -0,0 +1,36 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
+
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-07 19:44 ` Jonathan Wakely
2020-10-07 21:53 ` Thomas Rodgers
@ 2020-10-08 1:15 ` Thomas Rodgers
2020-10-08 16:30 ` Jonathan Wakely
1 sibling, 1 reply; 20+ messages in thread
From: Thomas Rodgers @ 2020-10-08 1:15 UTC (permalink / raw)
To: gcc-patches, libstdc++; +Cc: trodgers
From: Thomas Rodgers <trodgers@redhat.com>
New ctors and ::view() accessor for -
* basic_stingbuf
* basic_istringstream
* basic_ostringstream
* basic_stringstreamm
New ::get_allocator() accessor for basic_stringbuf.
libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
* config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
basic_stringbuf::basic_stringbuf(allocator const&),
basic_stringbuf::basic_stringbuf(openmode, allocator const&),
basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
basic_stringbuf::get_allocator(),
basic_stringbuf::view(),
basic_istringstream::basic_istringstream(basic_string&&, openmode),
basic_istringstream::basic_istringstream(openmode, allocator const&),
basic_istringstream::view(),
basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
basic_ostringstream::basic_ostringstream(openmode, allocator const&),
basic_ostringstream::view(),
basic_stringstream::basic_stringstream(basic_string&&, openmode),
basic_stringstream::basic_stringstream(openmode, allocator const&),
basic_stringstream::view().
* configure: Regenerate.
* include/std/sstream:
(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
(basic_stringbuf::get_allocator()): New method.
(basic_stringbuf::view()): Likewise.
(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
New constructor.
(basic_istringstream::basic_istringstream(openmode, allocator const&)):
Likewise
(basic_istringstream::view()): New method.
(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
New constructor.
(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
Likewise
(basic_ostringstream::view()): New method.
(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
New constructor.
(basic_stringstream::basic_stringstream(openmode, allocator const&)):
Likewise
(basic_stringstream::view()): New method.
* src/Makefile.in: Add c++20 directory.
* src/Makefile.am: Regenerate.
* src/c++20/Makefile.am: Add makefile for new sub-directory.
* src/c++20/Makefile.in: Generate.
* src/c++20/sstream-inst.cc: New file defining explicit
instantiations for basic_stringbuf, basic_istringstream,
basic_ostringstream, and basic_stringstream member functions
added in C++20.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
---
libstdc++-v3/acinclude.m4 | 2 +-
libstdc++-v3/config/abi/pre/gnu.ver | 45 ++
libstdc++-v3/configure | 16 +-
libstdc++-v3/include/std/sstream | 196 +++++
libstdc++-v3/src/Makefile.am | 12 +-
libstdc++-v3/src/Makefile.in | 14 +-
libstdc++-v3/src/c++20/Makefile.am | 105 +++
libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
libstdc++-v3/src/c++20/sstream-inst.cc | 111 +++
.../27_io/basic_istringstream/cons/char/1.cc | 85 ++
.../basic_istringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_istringstream/view/char/1.cc | 35 +
.../basic_istringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_ostringstream/cons/char/1.cc | 85 ++
.../basic_ostringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_ostringstream/view/char/1.cc | 35 +
.../basic_ostringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringbuf/cons/char/2.cc | 121 +++
.../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++
.../27_io/basic_stringbuf/view/char/1.cc | 35 +
.../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringstream/cons/char/1.cc | 85 ++
.../basic_stringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_stringstream/view/char/1.cc | 35 +
.../basic_stringstream/view/wchar_t/1.cc | 35 +
25 files changed, 2240 insertions(+), 12 deletions(-)
create mode 100644 libstdc++-v3/src/c++20/Makefile.am
create mode 100644 libstdc++-v3/src/c++20/Makefile.in
create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 133125ec4fa..b9452dd74cd 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 6a2b2da33f5..a782776bd5f 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2325,6 +2325,51 @@ GLIBCXX_3.4.29 {
# std::__throw_bad_array_new_length()
_ZSt28__throw_bad_array_new_lengthv;
+ # basic_stringbuf::basic_stringbuf(allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
+
+ # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
+
+ # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
+
+ # basic_stringbuf::get_allocator()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
+
+ # basic_stringbuf::view()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_istringstream::view()
+ _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_ostringstream::view()
+ _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_stringstream::view()
+ _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
} GLIBCXX_3.4.28;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 9cca54d17d1..09a572881c2 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -165,6 +165,55 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_stringbuf(const allocator_type& __a)
+ : basic_stringbuf(ios_base::in | std::ios_base::out, __a)
+ { }
+
+ basic_stringbuf(ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode), _M_string(__a)
+ { }
+
+ explicit
+ basic_stringbuf(__string_type&& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out )
+ : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
+ { }
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ const allocator_type& __a )
+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a )
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode),
+ _M_string(static_cast<__sv_type>(__s), __a)
+ { }
+
+ template<typename _SAlloc>
+ explicit
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringbuf(__s, __mode, allocator_type{})
+ { }
+
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
+ : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this))
+ { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); }
+
+ allocator_type get_allocator() const noexcept
+ { return _M_string.get_allocator(); }
+#endif
+
// Get and set:
/**
* @brief Copying out the string buffer.
@@ -207,6 +256,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_stringbuf_init(_M_mode);
}
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ {
+ if (this->pptr())
+ {
+ // The current egptr() may not be the actual string end.
+ if (this->pptr() > this->egptr())
+ return __sv_type(this->pbase(), this->pptr());
+ else
+ return __sv_type(this->pbase(), this->egptr());
+ }
+ else
+ return static_cast<__sv_type>(_M_string);
+ }
+#endif
+
protected:
// Common initialization code goes here.
void
@@ -369,6 +435,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
: __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
_M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
{ }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ // The move constructor initializes an __xfer_bufptrs temporary then
+ // delegates to this constructor to performs moves during its lifetime.
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a,
+ __xfer_bufptrs&&)
+ : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
+ _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a)
+ { }
+#endif
#endif
};
@@ -500,6 +576,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_istringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::in )
+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_istringstream(__str, ios_base::in, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __istream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::in, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in)
+ : basic_istringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -528,6 +638,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -658,6 +774,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_ostringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out )
+ : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_ostringstream(__str, ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __ostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::out, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::out)
+ : basic_ostringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -686,6 +836,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -812,6 +968,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_stringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(), _M_stringbuf(__mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_stringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out
+ | ios_base::out)
+ : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_stringstream(__str, ios_base::in | ios_base::out, __a)
+ { }
+
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ template<typename _SAlloc>
+ explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -840,6 +1030,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
#if __cplusplus >= 201103L
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index a139adc81b3..9a6807ae8c6 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -29,7 +29,7 @@ filesystem_dir =
endif
## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
-SUBDIRS = c++98 c++11 c++17 $(filesystem_dir)
+SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
# Cross compiler support.
if VTV_CYGMIN
@@ -60,6 +60,7 @@ endif
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
vpath % $(top_srcdir)/src/c++17
+vpath % $(top_srcdir)/src/c++20
if ENABLE_FILESYSTEM_TS
vpath % $(top_srcdir)/src/filesystem
endif
@@ -95,14 +96,16 @@ libstdc___la_LIBADD = \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_DEPENDENCIES = \
${version_dep} \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_LDFLAGS = \
-version-info $(libtool_VERSION) ${version_arg} -lm
@@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc
# segregated in the sources with -D_GLIBCXX_SHARED.
#
# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
-# only -prefer-pic objects are generated for the convenience libraries.
+# src/c++20, only -prefer-pic objects are generated for the convenience
+# libraries.
#
# In the main src directory, make shared and static objects just for
# the compat libraries. Shared objects are compiled with -prefer-pic
diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am
new file mode 100644
index 00000000000..423a79f3686
--- /dev/null
+++ b/libstdc++-v3/src/c++20/Makefile.am
@@ -0,0 +1,105 @@
+## Makefile for the C++20 sources of the GNU C++ Standard library.
+##
+## Copyright (C) 1997-2020 Free Software Foundation, Inc.
+##
+## This file is part of the libstdc++ version 3 distribution.
+## Process this file with automake to produce Makefile.in.
+
+## This file is part of the GNU ISO C++ Library. This library is free
+## software; you can redistribute it and/or modify it under the
+## terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 3, or (at your option)
+## any later version.
+
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License along
+## with this library; see the file COPYING3. If not see
+## <http://www.gnu.org/licenses/>.
+
+include $(top_srcdir)/fragment.am
+
+# Convenience library for C++17 runtime.
+noinst_LTLIBRARIES = libc++20convenience.la
+
+headers =
+
+if ENABLE_EXTERN_TEMPLATE
+# XTEMPLATE_FLAGS = -fno-implicit-templates
+inst_sources = \
+ sstream-inst.cc
+else
+# XTEMPLATE_FLAGS =
+inst_sources =
+endif
+
+sources =
+
+vpath % $(top_srcdir)/src/c++20
+
+libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
+
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way. Need to manually
+# set this option because CONFIG_CXXFLAGS has to be after
+# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+# as the occasion calls for it.
+AM_CXXFLAGS = \
+ -std=gnu++20 \
+ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
+ -fimplicit-templates
+
+AM_MAKEFLAGS = \
+ "gxx_include_dir=$(gxx_include_dir)"
+
+# Libtool notes
+
+# 1) In general, libtool expects an argument such as `--tag=CXX' when
+# using the C++ compiler, because that will enable the settings
+# detected when C++ support was being configured. However, when no
+# such flag is given in the command line, libtool attempts to figure
+# it out by matching the compiler name in each configuration section
+# against a prefix of the command line. The problem is that, if the
+# compiler name and its initial flags stored in the libtool
+# configuration file don't match those in the command line, libtool
+# can't decide which configuration to use, and it gives up. The
+# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
+# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
+# attempt to infer which configuration to use.
+#
+# The second tag argument, `--tag disable-shared` means that libtool
+# only compiles each source once, for static objects. In actuality,
+# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
+# the libtool command that is used create the object, which is
+# suitable for shared libraries. The `--tag disable-shared` must be
+# placed after --tag CXX lest things CXX undo the affect of
+# disable-shared.
+
+# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
+# last. (That way, things like -O2 passed down from the toplevel can
+# be overridden by --enable-debug.)
+LTCXXCOMPILE = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
+
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
+
+# 3) We'd have a problem when building the shared libstdc++ object if
+# the rules automake generates would be used. We cannot allow g++ to
+# be used since this would add -lstdc++ to the link line which of
+# course is problematic at this point. So, we get the top-level
+# directory to configure libstdc++-v3 to use gcc as the C++
+# compilation driver.
+CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+ $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
new file mode 100644
index 00000000000..0e2de19ae59
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
new file mode 100644
index 00000000000..c419176ae8e
--- /dev/null
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -0,0 +1,111 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<char>::allocator_type
+basic_stringbuf<char>::get_allocator() const noexcept;
+template basic_stringbuf<char>::__sv_type
+basic_stringbuf<char>::view() const noexcept;
+
+
+template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<char>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<char>::__sv_type
+basic_istringstream<char>::view() const noexcept;
+
+template basic_ostringstream<char>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<char>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<char>::__sv_type
+basic_ostringstream<char>::view() const noexcept;
+
+template basic_stringstream<char>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<char>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<char>::__sv_type
+basic_stringstream<char>::view() const noexcept;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::allocator_type
+basic_stringbuf<wchar_t>::get_allocator() const noexcept;
+
+template basic_stringbuf<wchar_t>::__sv_type
+basic_stringbuf<wchar_t>::view() const noexcept;
+
+template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<wchar_t>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template basic_istringstream<wchar_t>::__sv_type
+basic_istringstream<wchar_t>::view() const noexcept;
+
+template basic_ostringstream<wchar_t>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<wchar_t>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template basic_ostringstream<wchar_t>::__sv_type
+basic_ostringstream<wchar_t>::view() const noexcept;
+
+template basic_stringstream<wchar_t>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<wchar_t>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template basic_stringstream<wchar_t>::__sv_type
+basic_stringstream<wchar_t>::view() const noexcept;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
new file mode 100644
index 00000000000..d93141fc232
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::istringstream::allocator_type a;
+ std::istringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::istringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::istringstream::allocator_type a;
+ std::istringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..f89402fd24e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
new file mode 100644
index 00000000000..091de5f7a79
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::istringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..f6599643bd9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wistringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
new file mode 100644
index 00000000000..bfc026de65e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::ostringstream::allocator_type a;
+ std::ostringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::ostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::ostringstream::allocator_type a;
+ std::ostringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..07b2613cbbb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wostringstream::allocator_type a;
+ std::wostringstream stm(std::ios_base::out, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wostringstream::allocator_type a;
+ std::wostringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
new file mode 100644
index 00000000000..a366363abb5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::ostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..1ebf7c505e3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
new file mode 100644
index 00000000000..ce669358c85
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
@@ -0,0 +1,121 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ {
+ using alloc_type = __gnu_test::uneq_allocator<char>;
+ using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
+ alloc_type>;
+
+ alloc_type aa;
+ sbuf_t sbuf1(aa);
+ VERIFY( aa == sbuf1.get_allocator() );
+
+ alloc_type aaa(42);
+ sbuf_t sbuf2(aaa);
+ VERIFY( aaa == sbuf2.get_allocator() );
+
+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
+ }
+
+ std::stringbuf::allocator_type a;
+ {
+ std::stringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::stringbuf sbuf(a);
+ }
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::stringbuf sbuf1(cstr);
+
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::string s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
new file mode 100644
index 00000000000..e05acc42165
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
@@ -0,0 +1,105 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wstringbuf::allocator_type a;
+ {
+ std::wstringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::wstringbuf sbuf(a);
+ }
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wstringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::wstringbuf sbuf1(cstr);
+
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::wstring s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
new file mode 100644
index 00000000000..8f8c62daa21
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
new file mode 100644
index 00000000000..0d23d7d8e66
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
new file mode 100644
index 00000000000..accb1d3b4ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stringstream::allocator_type a;
+ std::stringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringstream::allocator_type a;
+ std::stringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..f89402fd24e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
new file mode 100644
index 00000000000..f47035cf148
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..d707cfed243
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-08 1:15 ` Thomas Rodgers
@ 2020-10-08 16:30 ` Jonathan Wakely
2020-10-09 23:28 ` Thomas Rodgers
2020-10-26 20:47 ` Thomas Rodgers
0 siblings, 2 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-08 16:30 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, trodgers
On 07/10/20 18:15 -0700, Thomas Rodgers wrote:
>@@ -500,6 +576,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> }
> #endif
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
>+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
>+ { this->init(&_M_stringbuf); }
All these & operators need to be std::__addressof(_M_stringbuf)
instead. _M_stringbuf potentially depends on program-defined types
(the traits and allocator classes) which means user namespaces are
considered for ADL and they could define a operator& that gets used.
>+
>+ explicit basic_istringstream(__string_type&& __str,
>+ ios_base::openmode __mode = ios_base::in )
>+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
>+ { this->init(&_M_stringbuf); }
>+
>+ template<typename _SAlloc>
>+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ const allocator_type& __a)
>+ : basic_istringstream(__str, ios_base::in, __a)
>+ { }
>+
>+ using __sv_type = basic_string_view<char_type, traits_type>;
This typedef seems to only be used once. Might as well just use
basic_string_view<char_type, traits_type> directly in the return type
of view().
Similarly in basic_ostringstream and basic_stringstream.
>diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
>new file mode 100644
>index 00000000000..0e2de19ae59
>diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
>new file mode 100644
>index 00000000000..c419176ae8e
>--- /dev/null
>+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
>@@ -0,0 +1,111 @@
>+// Explicit instantiation file.
>+
>+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
Just 2020 here.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// Under Section 7 of GPL version 3, you are granted additional
>+// permissions described in the GCC Runtime Library Exception, version
>+// 3.1, as published by the Free Software Foundation.
>+
>+// You should have received a copy of the GNU General Public License and
>+// a copy of the GCC Runtime Library Exception along with this program;
>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>+// <http://www.gnu.org/licenses/>.
>+
>+//
>+// ISO C++ 14882:
>+//
>+
>+#ifndef _GLIBCXX_USE_CXX11_ABI
>+// Instantiations in this file use the new SSO std::string ABI unless included
>+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
This copy&pasted comment is misleading now if we're not actually going
to include it from another file to generate the old ABI symbols.
I think just define it unconditionally and add a comment saying that
these new symbols are only defines for the SSO string ABI.
>+# define _GLIBCXX_USE_CXX11_ABI 1
>+#endif
>+#include <sstream>
>+
>+namespace std _GLIBCXX_VISIBILITY(default)
>+{
>+_GLIBCXX_BEGIN_NAMESPACE_VERSION
>+
>+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
>+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
>+ const allocator_type&);
>+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
>+ ios_base::openmode);
>+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
>+ const allocator_type&);
>+template basic_stringbuf<char>::allocator_type
>+basic_stringbuf<char>::get_allocator() const noexcept;
>+template basic_stringbuf<char>::__sv_type
Looks like this would be a bit simpler if it just used string_view
here, not basic_stringbuf<char>::__sv_type, and wstring_view below
for the wchar_t specializations.
And you could use allocator<char> instead of
basic_stringbuf<char>::allocator_type.
That looks a little cleaner to me, but it's a matter of opinion.
That would be necessary anyway for the basic_*stringstream types if
they don't have the __sv_type any more.
>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>new file mode 100644
>index 00000000000..d93141fc232
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
These references are to the C++03 standard, but the functions being
tested are not in that standard, or that section.
It's 29.8.2.2 [stringbuf.cons] in the C++20 standard. To make these
references unambiguous I've switched to saying which standard (or
which Nxxxx working draft) the reference comes from, i.e.
// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons]
One day I might write a script to add "C++03" or "C++11" to all the
old comments in old tests. When I drain my TODO list of other things.
I was expecting this patch to also add the five new overloads of
basic_stringbuf::str, but that can be added later. I don't think
adding those will change anything done in this patch.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-08 16:30 ` Jonathan Wakely
@ 2020-10-09 23:28 ` Thomas Rodgers
2020-10-13 16:46 ` Jonathan Wakely
2020-10-26 20:47 ` Thomas Rodgers
1 sibling, 1 reply; 20+ messages in thread
From: Thomas Rodgers @ 2020-10-09 23:28 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Thomas Rodgers, gcc-patches, libstdc++
Jonathan Wakely writes:
> On 07/10/20 18:15 -0700, Thomas Rodgers wrote:
>>@@ -500,6 +576,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
>> }
>> #endif
>>
>>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>>+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
>>+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
>>+ { this->init(&_M_stringbuf); }
>
> All these & operators need to be std::__addressof(_M_stringbuf)
> instead. _M_stringbuf potentially depends on program-defined types
> (the traits and allocator classes) which means user namespaces are
> considered for ADL and they could define a operator& that gets used.
>
>
>>+
>>+ explicit basic_istringstream(__string_type&& __str,
>>+ ios_base::openmode __mode = ios_base::in )
>>+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
>>+ { this->init(&_M_stringbuf); }
>>+
>>+ template<typename _SAlloc>
>>+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>>+ const allocator_type& __a)
>>+ : basic_istringstream(__str, ios_base::in, __a)
>>+ { }
>>+
>>+ using __sv_type = basic_string_view<char_type, traits_type>;
>
> This typedef seems to only be used once. Might as well just use
> basic_string_view<char_type, traits_type> directly in the return type
> of view().
>
> Similarly in basic_ostringstream and basic_stringstream.
>
>>diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
>>new file mode 100644
>>index 00000000000..0e2de19ae59
>>diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
>>new file mode 100644
>>index 00000000000..c419176ae8e
>>--- /dev/null
>>+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
>>@@ -0,0 +1,111 @@
>>+// Explicit instantiation file.
>>+
>>+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
>
> Just 2020 here.
>
>>+//
>>+// This file is part of the GNU ISO C++ Library. This library is free
>>+// software; you can redistribute it and/or modify it under the
>>+// terms of the GNU General Public License as published by the
>>+// Free Software Foundation; either version 3, or (at your option)
>>+// any later version.
>>+
>>+// This library is distributed in the hope that it will be useful,
>>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>+// GNU General Public License for more details.
>>+
>>+// Under Section 7 of GPL version 3, you are granted additional
>>+// permissions described in the GCC Runtime Library Exception, version
>>+// 3.1, as published by the Free Software Foundation.
>>+
>>+// You should have received a copy of the GNU General Public License and
>>+// a copy of the GCC Runtime Library Exception along with this program;
>>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>>+// <http://www.gnu.org/licenses/>.
>>+
>>+//
>>+// ISO C++ 14882:
>>+//
>>+
>>+#ifndef _GLIBCXX_USE_CXX11_ABI
>>+// Instantiations in this file use the new SSO std::string ABI unless included
>>+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
>
> This copy&pasted comment is misleading now if we're not actually going
> to include it from another file to generate the old ABI symbols.
>
> I think just define it unconditionally and add a comment saying that
> these new symbols are only defines for the SSO string ABI.
>
>>+# define _GLIBCXX_USE_CXX11_ABI 1
>>+#endif
>>+#include <sstream>
>>+
>>+namespace std _GLIBCXX_VISIBILITY(default)
>>+{
>>+_GLIBCXX_BEGIN_NAMESPACE_VERSION
>>+
>>+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
>>+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
>>+ const allocator_type&);
>>+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
>>+ ios_base::openmode);
>>+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
>>+ const allocator_type&);
>>+template basic_stringbuf<char>::allocator_type
>>+basic_stringbuf<char>::get_allocator() const noexcept;
>>+template basic_stringbuf<char>::__sv_type
>
> Looks like this would be a bit simpler if it just used string_view
> here, not basic_stringbuf<char>::__sv_type, and wstring_view below
> for the wchar_t specializations.
>
> And you could use allocator<char> instead of
> basic_stringbuf<char>::allocator_type.
>
> That looks a little cleaner to me, but it's a matter of opinion.
>
> That would be necessary anyway for the basic_*stringstream types if
> they don't have the __sv_type any more.
>
>
>>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>>new file mode 100644
>>index 00000000000..d93141fc232
>>--- /dev/null
>>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>>@@ -0,0 +1,85 @@
>>+// Copyright (C) 2020 Free Software Foundation, Inc.
>>+//
>>+// This file is part of the GNU ISO C++ Library. This library is free
>>+// software; you can redistribute it and/or modify it under the
>>+// terms of the GNU General Public License as published by the
>>+// Free Software Foundation; either version 3, or (at your option)
>>+// any later version.
>>+
>>+// This library is distributed in the hope that it will be useful,
>>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>+// GNU General Public License for more details.
>>+
>>+// You should have received a copy of the GNU General Public License along
>>+// with this library; see the file COPYING3. If not see
>>+// <http://www.gnu.org/licenses/>.
>>+
>>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>
> These references are to the C++03 standard, but the functions being
> tested are not in that standard, or that section.
>
> It's 29.8.2.2 [stringbuf.cons] in the C++20 standard. To make these
> references unambiguous I've switched to saying which standard (or
> which Nxxxx working draft) the reference comes from, i.e.
>
> // C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons]
>
> One day I might write a script to add "C++03" or "C++11" to all the
> old comments in old tests. When I drain my TODO list of other things.
>
> I was expecting this patch to also add the five new overloads of
> basic_stringbuf::str, but that can be added later. I don't think
> adding those will change anything done in this patch.
I'm happy to do that, follow up patch?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-09 23:28 ` Thomas Rodgers
@ 2020-10-13 16:46 ` Jonathan Wakely
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-13 16:46 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++
On 09/10/20 16:28 -0700, Thomas Rodgers via Libstdc++ wrote:
>
>Jonathan Wakely writes:
>
>> On 07/10/20 18:15 -0700, Thomas Rodgers wrote:
>>>@@ -500,6 +576,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
>>> }
>>> #endif
>>>
>>>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>>>+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
>>>+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
>>>+ { this->init(&_M_stringbuf); }
>>
>> All these & operators need to be std::__addressof(_M_stringbuf)
>> instead. _M_stringbuf potentially depends on program-defined types
>> (the traits and allocator classes) which means user namespaces are
>> considered for ADL and they could define a operator& that gets used.
>>
>>
>>>+
>>>+ explicit basic_istringstream(__string_type&& __str,
>>>+ ios_base::openmode __mode = ios_base::in )
>>>+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
>>>+ { this->init(&_M_stringbuf); }
>>>+
>>>+ template<typename _SAlloc>
>>>+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>>>+ const allocator_type& __a)
>>>+ : basic_istringstream(__str, ios_base::in, __a)
>>>+ { }
>>>+
>>>+ using __sv_type = basic_string_view<char_type, traits_type>;
>>
>> This typedef seems to only be used once. Might as well just use
>> basic_string_view<char_type, traits_type> directly in the return type
>> of view().
>>
>> Similarly in basic_ostringstream and basic_stringstream.
>>
>>>diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
>>>new file mode 100644
>>>index 00000000000..0e2de19ae59
>>>diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
>>>new file mode 100644
>>>index 00000000000..c419176ae8e
>>>--- /dev/null
>>>+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
>>>@@ -0,0 +1,111 @@
>>>+// Explicit instantiation file.
>>>+
>>>+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
>>
>> Just 2020 here.
>>
>>>+//
>>>+// This file is part of the GNU ISO C++ Library. This library is free
>>>+// software; you can redistribute it and/or modify it under the
>>>+// terms of the GNU General Public License as published by the
>>>+// Free Software Foundation; either version 3, or (at your option)
>>>+// any later version.
>>>+
>>>+// This library is distributed in the hope that it will be useful,
>>>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>>+// GNU General Public License for more details.
>>>+
>>>+// Under Section 7 of GPL version 3, you are granted additional
>>>+// permissions described in the GCC Runtime Library Exception, version
>>>+// 3.1, as published by the Free Software Foundation.
>>>+
>>>+// You should have received a copy of the GNU General Public License and
>>>+// a copy of the GCC Runtime Library Exception along with this program;
>>>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>>>+// <http://www.gnu.org/licenses/>.
>>>+
>>>+//
>>>+// ISO C++ 14882:
>>>+//
>>>+
>>>+#ifndef _GLIBCXX_USE_CXX11_ABI
>>>+// Instantiations in this file use the new SSO std::string ABI unless included
>>>+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
>>
>> This copy&pasted comment is misleading now if we're not actually going
>> to include it from another file to generate the old ABI symbols.
>>
>> I think just define it unconditionally and add a comment saying that
>> these new symbols are only defines for the SSO string ABI.
>>
>>>+# define _GLIBCXX_USE_CXX11_ABI 1
>>>+#endif
>>>+#include <sstream>
>>>+
>>>+namespace std _GLIBCXX_VISIBILITY(default)
>>>+{
>>>+_GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>+
>>>+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
>>>+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
>>>+ const allocator_type&);
>>>+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
>>>+ ios_base::openmode);
>>>+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
>>>+ const allocator_type&);
>>>+template basic_stringbuf<char>::allocator_type
>>>+basic_stringbuf<char>::get_allocator() const noexcept;
>>>+template basic_stringbuf<char>::__sv_type
>>
>> Looks like this would be a bit simpler if it just used string_view
>> here, not basic_stringbuf<char>::__sv_type, and wstring_view below
>> for the wchar_t specializations.
>>
>> And you could use allocator<char> instead of
>> basic_stringbuf<char>::allocator_type.
>>
>> That looks a little cleaner to me, but it's a matter of opinion.
>>
>> That would be necessary anyway for the basic_*stringstream types if
>> they don't have the __sv_type any more.
>>
>>
>>>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>>>new file mode 100644
>>>index 00000000000..d93141fc232
>>>--- /dev/null
>>>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>>>@@ -0,0 +1,85 @@
>>>+// Copyright (C) 2020 Free Software Foundation, Inc.
>>>+//
>>>+// This file is part of the GNU ISO C++ Library. This library is free
>>>+// software; you can redistribute it and/or modify it under the
>>>+// terms of the GNU General Public License as published by the
>>>+// Free Software Foundation; either version 3, or (at your option)
>>>+// any later version.
>>>+
>>>+// This library is distributed in the hope that it will be useful,
>>>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>>+// GNU General Public License for more details.
>>>+
>>>+// You should have received a copy of the GNU General Public License along
>>>+// with this library; see the file COPYING3. If not see
>>>+// <http://www.gnu.org/licenses/>.
>>>+
>>>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>>
>> These references are to the C++03 standard, but the functions being
>> tested are not in that standard, or that section.
>>
>> It's 29.8.2.2 [stringbuf.cons] in the C++20 standard. To make these
>> references unambiguous I've switched to saying which standard (or
>> which Nxxxx working draft) the reference comes from, i.e.
>>
>> // C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons]
>>
>> One day I might write a script to add "C++03" or "C++11" to all the
>> old comments in old tests. When I drain my TODO list of other things.
>>
>> I was expecting this patch to also add the five new overloads of
>> basic_stringbuf::str, but that can be added later. I don't think
>> adding those will change anything done in this patch.
>
>I'm happy to do that, follow up patch?
Yes, keep it separate.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-08 16:30 ` Jonathan Wakely
2020-10-09 23:28 ` Thomas Rodgers
@ 2020-10-26 20:47 ` Thomas Rodgers
2020-10-26 21:09 ` Jonathan Wakely
1 sibling, 1 reply; 20+ messages in thread
From: Thomas Rodgers @ 2020-10-26 20:47 UTC (permalink / raw)
To: gcc-patches, libstdc++; +Cc: trodgers
From: Thomas Rodgers <trodgers@redhat.com>
New ctors and ::view() accessor for -
* basic_stingbuf
* basic_istringstream
* basic_ostringstream
* basic_stringstreamm
New ::get_allocator() accessor for basic_stringbuf.
libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
* config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
basic_stringbuf::basic_stringbuf(allocator const&),
basic_stringbuf::basic_stringbuf(openmode, allocator const&),
basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
basic_stringbuf::get_allocator(),
basic_stringbuf::view(),
basic_istringstream::basic_istringstream(basic_string&&, openmode),
basic_istringstream::basic_istringstream(openmode, allocator const&),
basic_istringstream::view(),
basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
basic_ostringstream::basic_ostringstream(openmode, allocator const&),
basic_ostringstream::view(),
basic_stringstream::basic_stringstream(basic_string&&, openmode),
basic_stringstream::basic_stringstream(openmode, allocator const&),
basic_stringstream::view().
* configure: Regenerate.
* include/std/sstream:
(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
(basic_stringbuf::get_allocator()): New method.
(basic_stringbuf::view()): Likewise.
(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
New constructor.
(basic_istringstream::basic_istringstream(openmode, allocator const&)):
Likewise
(basic_istringstream::view()): New method.
(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
New constructor.
(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
Likewise
(basic_ostringstream::view()): New method.
(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
New constructor.
(basic_stringstream::basic_stringstream(openmode, allocator const&)):
Likewise
(basic_stringstream::view()): New method.
* src/Makefile.in: Add c++20 directory.
* src/Makefile.am: Regenerate.
* src/c++20/Makefile.am: Add makefile for new sub-directory.
* src/c++20/Makefile.in: Generate.
* src/c++20/sstream-inst.cc: New file defining explicit
instantiations for basic_stringbuf, basic_istringstream,
basic_ostringstream, and basic_stringstream member functions
added in C++20.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
---
libstdc++-v3/acinclude.m4 | 2 +-
libstdc++-v3/config/abi/pre/gnu.ver | 45 ++
libstdc++-v3/configure | 16 +-
libstdc++-v3/include/std/sstream | 190 +++++
libstdc++-v3/src/Makefile.am | 12 +-
libstdc++-v3/src/Makefile.in | 14 +-
libstdc++-v3/src/c++20/Makefile.am | 105 +++
libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
libstdc++-v3/src/c++20/sstream-inst.cc | 108 +++
.../27_io/basic_istringstream/cons/char/1.cc | 85 ++
.../basic_istringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_istringstream/view/char/1.cc | 35 +
.../basic_istringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_ostringstream/cons/char/1.cc | 85 ++
.../basic_ostringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_ostringstream/view/char/1.cc | 35 +
.../basic_ostringstream/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringbuf/cons/char/2.cc | 121 +++
.../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++
.../27_io/basic_stringbuf/view/char/1.cc | 35 +
.../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 +
.../27_io/basic_stringstream/cons/char/1.cc | 85 ++
.../basic_stringstream/cons/wchar_t/1.cc | 85 ++
.../27_io/basic_stringstream/view/char/1.cc | 35 +
.../basic_stringstream/view/wchar_t/1.cc | 35 +
25 files changed, 2231 insertions(+), 12 deletions(-)
create mode 100644 libstdc++-v3/src/c++20/Makefile.am
create mode 100644 libstdc++-v3/src/c++20/Makefile.in
create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 133125ec4fa..b9452dd74cd 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 6a2b2da33f5..a782776bd5f 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2325,6 +2325,51 @@ GLIBCXX_3.4.29 {
# std::__throw_bad_array_new_length()
_ZSt28__throw_bad_array_new_lengthv;
+ # basic_stringbuf::basic_stringbuf(allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
+
+ # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
+
+ # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
+
+ # basic_stringbuf::get_allocator()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
+
+ # basic_stringbuf::view()
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_istringstream::view()
+ _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_ostringstream::view()
+ _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
+ # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
+
+ # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
+
+ # basic_stringstream::view()
+ _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
+
} GLIBCXX_3.4.28;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 9cca54d17d1..b191c471b39 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -165,6 +165,55 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
+ basic_stringbuf(const allocator_type& __a)
+ : basic_stringbuf(ios_base::in | std::ios_base::out, __a)
+ { }
+
+ basic_stringbuf(ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode), _M_string(__a)
+ { }
+
+ explicit
+ basic_stringbuf(__string_type&& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out )
+ : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
+ { }
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ const allocator_type& __a )
+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a )
+ { }
+
+ template<typename _SAlloc>
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode),
+ _M_string(static_cast<__sv_type>(__s), __a)
+ { }
+
+ template<typename _SAlloc>
+ explicit
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringbuf(__s, __mode, allocator_type{})
+ { }
+
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
+ : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this))
+ { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); }
+
+ allocator_type get_allocator() const noexcept
+ { return _M_string.get_allocator(); }
+#endif
+
// Get and set:
/**
* @brief Copying out the string buffer.
@@ -207,6 +256,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_stringbuf_init(_M_mode);
}
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ __sv_type
+ view() const noexcept
+ {
+ if (this->pptr())
+ {
+ // The current egptr() may not be the actual string end.
+ if (this->pptr() > this->egptr())
+ return __sv_type(this->pbase(), this->pptr());
+ else
+ return __sv_type(this->pbase(), this->egptr());
+ }
+ else
+ return static_cast<__sv_type>(_M_string);
+ }
+#endif
+
protected:
// Common initialization code goes here.
void
@@ -369,6 +435,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
: __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
_M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
{ }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ // The move constructor initializes an __xfer_bufptrs temporary then
+ // delegates to this constructor to performs moves during its lifetime.
+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a,
+ __xfer_bufptrs&&)
+ : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
+ _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a)
+ { }
+#endif
#endif
};
@@ -500,6 +576,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ explicit basic_istringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::in )
+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_istringstream(__str, ios_base::in, __a)
+ { }
+
+ template<typename _SAlloc>
+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __istream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::in, __a)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in)
+ : basic_istringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -528,6 +636,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_string_view<char_type, traits_type>
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -658,6 +772,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ explicit basic_ostringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out )
+ : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_ostringstream(__str, ios_base::out, __a)
+ { }
+
+ template<typename _SAlloc>
+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __ostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()),
+ __mode | ios_base::out, __a)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::out)
+ : basic_ostringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -686,6 +832,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_string_view<char_type, traits_type>
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
@@ -812,6 +964,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#endif
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_stringstream(ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(), _M_stringbuf(__mode, __a)
+ { this->init(&_M_stringbuf); }
+
+ explicit basic_stringstream(__string_type&& __str,
+ ios_base::openmode __mode = ios_base::out
+ | ios_base::out)
+ : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ const allocator_type& __a)
+ : basic_stringstream(__str, ios_base::in | ios_base::out, __a)
+ { }
+
+ template<typename _SAlloc>
+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode, const allocator_type& __a)
+ : __iostream_type(),
+ _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
+ { this->init(std::__addressof(_M_stringbuf)); }
+
+ template<typename _SAlloc>
+ explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
+ ios_base::openmode __mode = ios_base::in
+ | ios_base::out)
+ : basic_stringstream(__str, __mode, allocator_type())
+ { }
+#endif
+
// Members:
/**
* @brief Accessing the underlying buffer.
@@ -840,6 +1024,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
+
+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+ basic_string_view<char_type, traits_type>
+ view() const noexcept
+ { return _M_stringbuf.view(); }
+#endif
};
#if __cplusplus >= 201103L
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index a139adc81b3..9a6807ae8c6 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -29,7 +29,7 @@ filesystem_dir =
endif
## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
-SUBDIRS = c++98 c++11 c++17 $(filesystem_dir)
+SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
# Cross compiler support.
if VTV_CYGMIN
@@ -60,6 +60,7 @@ endif
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
vpath % $(top_srcdir)/src/c++17
+vpath % $(top_srcdir)/src/c++20
if ENABLE_FILESYSTEM_TS
vpath % $(top_srcdir)/src/filesystem
endif
@@ -95,14 +96,16 @@ libstdc___la_LIBADD = \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_DEPENDENCIES = \
${version_dep} \
$(top_builddir)/libsupc++/libsupc++convenience.la \
$(top_builddir)/src/c++98/libc++98convenience.la \
$(top_builddir)/src/c++11/libc++11convenience.la \
- $(top_builddir)/src/c++17/libc++17convenience.la
+ $(top_builddir)/src/c++17/libc++17convenience.la \
+ $(top_builddir)/src/c++20/libc++20convenience.la
libstdc___la_LDFLAGS = \
-version-info $(libtool_VERSION) ${version_arg} -lm
@@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc
# segregated in the sources with -D_GLIBCXX_SHARED.
#
# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
-# only -prefer-pic objects are generated for the convenience libraries.
+# src/c++20, only -prefer-pic objects are generated for the convenience
+# libraries.
#
# In the main src directory, make shared and static objects just for
# the compat libraries. Shared objects are compiled with -prefer-pic
diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am
new file mode 100644
index 00000000000..423a79f3686
--- /dev/null
+++ b/libstdc++-v3/src/c++20/Makefile.am
@@ -0,0 +1,105 @@
+## Makefile for the C++20 sources of the GNU C++ Standard library.
+##
+## Copyright (C) 1997-2020 Free Software Foundation, Inc.
+##
+## This file is part of the libstdc++ version 3 distribution.
+## Process this file with automake to produce Makefile.in.
+
+## This file is part of the GNU ISO C++ Library. This library is free
+## software; you can redistribute it and/or modify it under the
+## terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 3, or (at your option)
+## any later version.
+
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License along
+## with this library; see the file COPYING3. If not see
+## <http://www.gnu.org/licenses/>.
+
+include $(top_srcdir)/fragment.am
+
+# Convenience library for C++17 runtime.
+noinst_LTLIBRARIES = libc++20convenience.la
+
+headers =
+
+if ENABLE_EXTERN_TEMPLATE
+# XTEMPLATE_FLAGS = -fno-implicit-templates
+inst_sources = \
+ sstream-inst.cc
+else
+# XTEMPLATE_FLAGS =
+inst_sources =
+endif
+
+sources =
+
+vpath % $(top_srcdir)/src/c++20
+
+libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
+
+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
+# modified in a per-library or per-sub-library way. Need to manually
+# set this option because CONFIG_CXXFLAGS has to be after
+# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+# as the occasion calls for it.
+AM_CXXFLAGS = \
+ -std=gnu++20 \
+ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
+ -fimplicit-templates
+
+AM_MAKEFLAGS = \
+ "gxx_include_dir=$(gxx_include_dir)"
+
+# Libtool notes
+
+# 1) In general, libtool expects an argument such as `--tag=CXX' when
+# using the C++ compiler, because that will enable the settings
+# detected when C++ support was being configured. However, when no
+# such flag is given in the command line, libtool attempts to figure
+# it out by matching the compiler name in each configuration section
+# against a prefix of the command line. The problem is that, if the
+# compiler name and its initial flags stored in the libtool
+# configuration file don't match those in the command line, libtool
+# can't decide which configuration to use, and it gives up. The
+# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
+# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
+# attempt to infer which configuration to use.
+#
+# The second tag argument, `--tag disable-shared` means that libtool
+# only compiles each source once, for static objects. In actuality,
+# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
+# the libtool command that is used create the object, which is
+# suitable for shared libraries. The `--tag disable-shared` must be
+# placed after --tag CXX lest things CXX undo the affect of
+# disable-shared.
+
+# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
+# last. (That way, things like -O2 passed down from the toplevel can
+# be overridden by --enable-debug.)
+LTCXXCOMPILE = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
+
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
+
+# 3) We'd have a problem when building the shared libstdc++ object if
+# the rules automake generates would be used. We cannot allow g++ to
+# be used since this would add -lstdc++ to the link line which of
+# course is problematic at this point. So, we get the top-level
+# directory to configure libstdc++-v3 to use gcc as the C++
+# compilation driver.
+CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+ $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
new file mode 100644
index 00000000000..0e2de19ae59
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
new file mode 100644
index 00000000000..e04560d28c8
--- /dev/null
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -0,0 +1,108 @@
+// Explicit instantiation file.
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:
+//
+
+// Instantiations in this file are only for the new SSO std::string ABI
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<char>::allocator_type
+basic_stringbuf<char>::get_allocator() const noexcept;
+template basic_stringbuf<char>::__sv_type
+basic_stringbuf<char>::view() const noexcept;
+
+template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<char>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template string_view
+basic_istringstream<char>::view() const noexcept;
+
+template basic_ostringstream<char>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<char>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template string_view
+basic_ostringstream<char>::view() const noexcept;
+
+template basic_stringstream<char>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<char>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template string_view
+basic_stringstream<char>::view() const noexcept;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+using wsv_type = basic_string_view<wchar_t>;
+
+template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::basic_stringbuf(__string_type&&,
+ ios_base::openmode);
+template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
+ const allocator_type&);
+template basic_stringbuf<wchar_t>::allocator_type
+basic_stringbuf<wchar_t>::get_allocator() const noexcept;
+
+template basic_istringstream<wchar_t>::__stringbuf_type::__sv_type
+basic_stringbuf<wchar_t>::view() const noexcept;
+
+template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_istringstream<wchar_t>::basic_istringstream(__string_type&&,
+ ios_base::openmode);
+template wstring_view
+basic_istringstream<wchar_t>::view() const noexcept;
+
+template basic_ostringstream<wchar_t>::basic_ostringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_ostringstream<wchar_t>::basic_ostringstream(__string_type&&,
+ ios_base::openmode);
+template wstring_view
+basic_ostringstream<wchar_t>::view() const noexcept;
+
+template basic_stringstream<wchar_t>::basic_stringstream(ios_base::openmode,
+ const allocator_type&);
+template basic_stringstream<wchar_t>::basic_stringstream(__string_type&&,
+ ios_base::openmode);
+template wstring_view
+basic_stringstream<wchar_t>::view() const noexcept;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
new file mode 100644
index 00000000000..496aa6963e0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::istringstream::allocator_type a;
+ std::istringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::istringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::istringstream::allocator_type a;
+ std::istringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::istringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..26a3a86c46e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
new file mode 100644
index 00000000000..091de5f7a79
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::istringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..f6599643bd9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wistringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
new file mode 100644
index 00000000000..cba69f80931
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::ostringstream::allocator_type a;
+ std::ostringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::ostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::ostringstream::allocator_type a;
+ std::ostringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::ostringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..9021186d2c8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wostringstream::allocator_type a;
+ std::wostringstream stm(std::ios_base::out, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wostringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wostringstream::allocator_type a;
+ std::wostringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wostringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
new file mode 100644
index 00000000000..a366363abb5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::ostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..1ebf7c505e3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wostringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
new file mode 100644
index 00000000000..ce669358c85
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
@@ -0,0 +1,121 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ {
+ using alloc_type = __gnu_test::uneq_allocator<char>;
+ using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
+ alloc_type>;
+
+ alloc_type aa;
+ sbuf_t sbuf1(aa);
+ VERIFY( aa == sbuf1.get_allocator() );
+
+ alloc_type aaa(42);
+ sbuf_t sbuf2(aaa);
+ VERIFY( aaa == sbuf2.get_allocator() );
+
+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
+ }
+
+ std::stringbuf::allocator_type a;
+ {
+ std::stringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::stringbuf sbuf(a);
+ }
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringbuf sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::stringbuf sbuf1(cstr);
+
+ std::stringbuf::allocator_type a;
+ std::stringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::string s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
new file mode 100644
index 00000000000..e05acc42165
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
@@ -0,0 +1,105 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wstringbuf::allocator_type a;
+ {
+ std::wstringbuf sbuf(std::ios_base::in, a);
+ }
+
+ {
+ std::wstringbuf sbuf(a);
+ }
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wstringbuf sbuf(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wstringbuf sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+void
+test04()
+{
+ std::wstringbuf sbuf1(cstr);
+
+ std::wstringbuf::allocator_type a;
+ std::wstringbuf sbuf2(std::move(sbuf1), a);
+ VERIFY( sbuf1.str().empty() );
+
+ std::wstring s(cstr);
+ VERIFY( sbuf2.str() == s );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
new file mode 100644
index 00000000000..8f8c62daa21
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
new file mode 100644
index 00000000000..0d23d7d8e66
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringbuf sbuf(s);
+ VERIFY( sbuf.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
new file mode 100644
index 00000000000..83a3374b3cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stringstream::allocator_type a;
+ std::stringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = "This is a test";
+
+void
+test02()
+{
+ std::string s1(cstr);
+ std::stringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::string s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<char>;
+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
+
+ auto const mode = std::ios_base::in | std::ios_base::out;
+ str_type s1(cstr);
+
+ {
+ std::stringstream::allocator_type a;
+ std::stringstream sbuf(s1, mode, a);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1, mode);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::stringstream sbuf(s1);
+ std::string s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
new file mode 100644
index 00000000000..26a3a86c46e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::wistringstream::allocator_type a;
+ std::wistringstream stm(std::ios_base::in, a);
+}
+
+auto const cstr = L"This is a test";
+
+void
+test02()
+{
+ std::wstring s1(cstr);
+ std::wistringstream stm(std::move(s1));
+ VERIFY( s1.empty() );
+
+ std::wstring s2(cstr);
+ VERIFY( stm.str() == s2 );
+}
+
+void
+test03()
+{
+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
+
+ auto const mode = std::ios_base::in;
+ str_type s1(cstr);
+
+ {
+ std::wistringstream::allocator_type a;
+ std::wistringstream sbuf(s1, mode, a);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1, mode);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+
+ {
+ std::wistringstream sbuf(s1);
+ std::wstring s2(cstr);
+ VERIFY( sbuf.str() == s2 );
+ }
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
new file mode 100644
index 00000000000..f47035cf148
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::string s("This is a test");
+ std::stringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
new file mode 100644
index 00000000000..d707cfed243
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// { dg-require-effective-target cxx11-abi }
+
+#include <sstream>
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::wstring s(L"This is a test");
+ std::wstringstream stm(s);
+ VERIFY( stm.view() == s );
+ return 0;
+}
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-26 20:47 ` Thomas Rodgers
@ 2020-10-26 21:09 ` Jonathan Wakely
2020-10-28 23:59 ` Jonathan Wakely
0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-26 21:09 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, trodgers
On 26/10/20 13:47 -0700, Thomas Rodgers wrote:
>From: Thomas Rodgers <trodgers@redhat.com>
>
>New ctors and ::view() accessor for -
> * basic_stingbuf
> * basic_istringstream
> * basic_ostringstream
> * basic_stringstreamm
>
>New ::get_allocator() accessor for basic_stringbuf.
>
>libstdc++-v3/ChangeLog:
> * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
> * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
> basic_stringbuf::basic_stringbuf(allocator const&),
> basic_stringbuf::basic_stringbuf(openmode, allocator const&),
> basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
> basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
> basic_stringbuf::get_allocator(),
> basic_stringbuf::view(),
> basic_istringstream::basic_istringstream(basic_string&&, openmode),
> basic_istringstream::basic_istringstream(openmode, allocator const&),
> basic_istringstream::view(),
> basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
> basic_ostringstream::basic_ostringstream(openmode, allocator const&),
> basic_ostringstream::view(),
> basic_stringstream::basic_stringstream(basic_string&&, openmode),
> basic_stringstream::basic_stringstream(openmode, allocator const&),
> basic_stringstream::view().
As discussed on IRC< please don't name every one of these functions
for the linker script changes, it's just redundant noise. They're
already listed below in the include/std/sstream changes.
Look at past changelog entries for the gnu.ver file.
> * configure: Regenerate.
> * include/std/sstream:
> (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
> (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
> (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
> (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
New line before the Likewise.
There are a few formatting changes mentioned below. OK for trunk with
those changes. Thanks. Go ahead and commit the <syncstream> patch
after this one too.
> (basic_stringbuf::get_allocator()): New method.
> (basic_stringbuf::view()): Likewise.
> (basic_istringstream::basic_istringstream(basic_string&&, openmode)):
> New constructor.
> (basic_istringstream::basic_istringstream(openmode, allocator const&)):
> Likewise
> (basic_istringstream::view()): New method.
> (basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
> New constructor.
> (basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
> Likewise
> (basic_ostringstream::view()): New method.
> (basic_stringstream::basic_stringstream(basic_string&&, openmode)):
> New constructor.
> (basic_stringstream::basic_stringstream(openmode, allocator const&)):
> Likewise
> (basic_stringstream::view()): New method.
> * src/Makefile.in: Add c++20 directory.
> * src/Makefile.am: Regenerate.
> * src/c++20/Makefile.am: Add makefile for new sub-directory.
> * src/c++20/Makefile.in: Generate.
> * src/c++20/sstream-inst.cc: New file defining explicit
> instantiations for basic_stringbuf, basic_istringstream,
> basic_ostringstream, and basic_stringstream member functions
> added in C++20.
> * testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
> * testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
> * testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
>---
> libstdc++-v3/acinclude.m4 | 2 +-
> libstdc++-v3/config/abi/pre/gnu.ver | 45 ++
> libstdc++-v3/configure | 16 +-
> libstdc++-v3/include/std/sstream | 190 +++++
> libstdc++-v3/src/Makefile.am | 12 +-
> libstdc++-v3/src/Makefile.in | 14 +-
> libstdc++-v3/src/c++20/Makefile.am | 105 +++
> libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++
> libstdc++-v3/src/c++20/sstream-inst.cc | 108 +++
> .../27_io/basic_istringstream/cons/char/1.cc | 85 ++
> .../basic_istringstream/cons/wchar_t/1.cc | 85 ++
> .../27_io/basic_istringstream/view/char/1.cc | 35 +
> .../basic_istringstream/view/wchar_t/1.cc | 35 +
> .../27_io/basic_ostringstream/cons/char/1.cc | 85 ++
> .../basic_ostringstream/cons/wchar_t/1.cc | 85 ++
> .../27_io/basic_ostringstream/view/char/1.cc | 35 +
> .../basic_ostringstream/view/wchar_t/1.cc | 35 +
> .../27_io/basic_stringbuf/cons/char/2.cc | 121 +++
> .../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++
> .../27_io/basic_stringbuf/view/char/1.cc | 35 +
> .../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 +
> .../27_io/basic_stringstream/cons/char/1.cc | 85 ++
> .../basic_stringstream/cons/wchar_t/1.cc | 85 ++
> .../27_io/basic_stringstream/view/char/1.cc | 35 +
> .../basic_stringstream/view/wchar_t/1.cc | 35 +
> 25 files changed, 2231 insertions(+), 12 deletions(-)
> create mode 100644 libstdc++-v3/src/c++20/Makefile.am
> create mode 100644 libstdc++-v3/src/c++20/Makefile.in
> create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
> create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
>
>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>index 133125ec4fa..b9452dd74cd 100644
>--- a/libstdc++-v3/acinclude.m4
>+++ b/libstdc++-v3/acinclude.m4
>@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
> # Keep these sync'd with the list in Makefile.am. The first provides an
> # expandable list at autoconf time; the second provides an expandable list
> # (i.e., shell variable) at configure time.
>- m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python])
>+ m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
> SUBDIRS='glibcxx_SUBDIRS'
>
> # These need to be absolute paths, yet at the same time need to
>diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
>index 6a2b2da33f5..a782776bd5f 100644
>--- a/libstdc++-v3/config/abi/pre/gnu.ver
>+++ b/libstdc++-v3/config/abi/pre/gnu.ver
>@@ -2325,6 +2325,51 @@ GLIBCXX_3.4.29 {
> # std::__throw_bad_array_new_length()
> _ZSt28__throw_bad_array_new_lengthv;
>
>+ # basic_stringbuf::basic_stringbuf(allocator const&)
>+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
>+
>+ # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
>+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
>+
>+ # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
>+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>+
>+ # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
>+ _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
>+
>+ # basic_stringbuf::get_allocator()
>+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
>+
>+ # basic_stringbuf::view()
>+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>+
>+ # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
>+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>+
>+ # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
>+ _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
>+
>+ # basic_istringstream::view()
>+ _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>+
>+ # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
>+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>+
>+ # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
>+ _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
>+
>+ # basic_ostringstream::view()
>+ _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>+
>+ # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
>+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>+
>+ # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
>+ _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
>+
>+ # basic_stringstream::view()
>+ _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>+
> } GLIBCXX_3.4.28;
>
> # Symbols in the support library (libsupc++) have their own tag.
>diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
>index 9cca54d17d1..b191c471b39 100644
>--- a/libstdc++-v3/include/std/sstream
>+++ b/libstdc++-v3/include/std/sstream
>@@ -165,6 +165,55 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> }
> #endif
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ using __sv_type = basic_string_view<char_type, traits_type>;
>+
>+ basic_stringbuf(const allocator_type& __a)
>+ : basic_stringbuf(ios_base::in | std::ios_base::out, __a)
>+ { }
>+
>+ basic_stringbuf(ios_base::openmode __mode,
>+ const allocator_type& __a)
>+ : __streambuf_type(), _M_mode(__mode), _M_string(__a)
>+ { }
>+
>+ explicit
>+ basic_stringbuf(__string_type&& __s,
>+ ios_base::openmode __mode = ios_base::in
>+ | ios_base::out )
>+ : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
>+ { }
>+
>+ template<typename _SAlloc>
>+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
>+ const allocator_type& __a )
>+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a )
>+ { }
>+
>+ template<typename _SAlloc>
>+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
>+ ios_base::openmode __mode,
>+ const allocator_type& __a)
>+ : __streambuf_type(), _M_mode(__mode),
>+ _M_string(static_cast<__sv_type>(__s), __a)
>+ { }
>+
>+ template<typename _SAlloc>
>+ explicit
>+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
>+ ios_base::openmode __mode = ios_base::in
>+ | ios_base::out)
>+ : basic_stringbuf(__s, __mode, allocator_type{})
>+ { }
>+
>+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
>+ : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this))
>+ { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); }
>+
>+ allocator_type get_allocator() const noexcept
>+ { return _M_string.get_allocator(); }
>+#endif
>+
> // Get and set:
> /**
> * @brief Copying out the string buffer.
>@@ -207,6 +256,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> _M_stringbuf_init(_M_mode);
> }
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ __sv_type
>+ view() const noexcept
>+ {
>+ if (this->pptr())
>+ {
>+ // The current egptr() may not be the actual string end.
>+ if (this->pptr() > this->egptr())
>+ return __sv_type(this->pbase(), this->pptr());
>+ else
>+ return __sv_type(this->pbase(), this->egptr());
>+ }
>+ else
>+ return static_cast<__sv_type>(_M_string);
>+ }
>+#endif
>+
> protected:
> // Common initialization code goes here.
> void
>@@ -369,6 +435,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
> _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
> { }
>+
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ // The move constructor initializes an __xfer_bufptrs temporary then
>+ // delegates to this constructor to performs moves during its lifetime.
>+ basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a,
>+ __xfer_bufptrs&&)
>+ : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
>+ _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a)
>+ { }
>+#endif
> #endif
> };
>
>@@ -500,6 +576,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> }
> #endif
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_istringstream(ios_base::openmode __mode, const allocator_type& __a)
>+ : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ explicit basic_istringstream(__string_type&& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::in )
>+ : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ const allocator_type& __a)
>+ : basic_istringstream(__str, ios_base::in, __a)
>+ { }
>+
>+ template<typename _SAlloc>
>+ basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ ios_base::openmode __mode,
>+ const allocator_type& __a)
>+ : __istream_type(),
>+ _M_stringbuf(__string_type(__str.data(), __str.size()),
>+ __mode | ios_base::in, __a)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::in)
>+ : basic_istringstream(__str, __mode, allocator_type())
>+ { }
>+#endif
>+
> // Members:
> /**
> * @brief Accessing the underlying buffer.
>@@ -528,6 +636,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> void
> str(const __string_type& __s)
> { _M_stringbuf.str(__s); }
>+
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_string_view<char_type, traits_type>
>+ view() const noexcept
>+ { return _M_stringbuf.view(); }
>+#endif
> };
>
>
>@@ -658,6 +772,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> }
> #endif
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a)
>+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ explicit basic_ostringstream(__string_type&& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::out )
>+ : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ const allocator_type& __a)
>+ : basic_ostringstream(__str, ios_base::out, __a)
>+ { }
>+
>+ template<typename _SAlloc>
>+ basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ ios_base::openmode __mode,
>+ const allocator_type& __a)
>+ : __ostream_type(),
>+ _M_stringbuf(__string_type(__str.data(), __str.size()),
>+ __mode | ios_base::out, __a)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::out)
>+ : basic_ostringstream(__str, __mode, allocator_type())
>+ { }
>+#endif
>+
> // Members:
> /**
> * @brief Accessing the underlying buffer.
>@@ -686,6 +832,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> void
> str(const __string_type& __s)
> { _M_stringbuf.str(__s); }
>+
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_string_view<char_type, traits_type>
>+ view() const noexcept
>+ { return _M_stringbuf.view(); }
>+#endif
> };
>
>
>@@ -812,6 +964,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> }
> #endif
>
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_stringstream(ios_base::openmode __mode, const allocator_type& __a)
>+ : __iostream_type(), _M_stringbuf(__mode, __a)
>+ { this->init(&_M_stringbuf); }
>+
>+ explicit basic_stringstream(__string_type&& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::out
>+ | ios_base::out)
>+ : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ const allocator_type& __a)
>+ : basic_stringstream(__str, ios_base::in | ios_base::out, __a)
>+ { }
>+
>+ template<typename _SAlloc>
>+ basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
>+ ios_base::openmode __mode, const allocator_type& __a)
>+ : __iostream_type(),
>+ _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
>+ { this->init(std::__addressof(_M_stringbuf)); }
>+
>+ template<typename _SAlloc>
>+ explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
Newline after explicit.
>+ ios_base::openmode __mode = ios_base::in
>+ | ios_base::out)
>+ : basic_stringstream(__str, __mode, allocator_type())
>+ { }
>+#endif
>+
> // Members:
> /**
> * @brief Accessing the underlying buffer.
>@@ -840,6 +1024,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> void
> str(const __string_type& __s)
> { _M_stringbuf.str(__s); }
>+
>+#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
>+ basic_string_view<char_type, traits_type>
>+ view() const noexcept
>+ { return _M_stringbuf.view(); }
>+#endif
> };
>
> #if __cplusplus >= 201103L
>diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
>index a139adc81b3..9a6807ae8c6 100644
>--- a/libstdc++-v3/src/Makefile.am
>+++ b/libstdc++-v3/src/Makefile.am
>@@ -29,7 +29,7 @@ filesystem_dir =
> endif
>
> ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
>-SUBDIRS = c++98 c++11 c++17 $(filesystem_dir)
>+SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
>
> # Cross compiler support.
> if VTV_CYGMIN
>@@ -60,6 +60,7 @@ endif
> vpath % $(top_srcdir)/src/c++98
> vpath % $(top_srcdir)/src/c++11
> vpath % $(top_srcdir)/src/c++17
>+vpath % $(top_srcdir)/src/c++20
> if ENABLE_FILESYSTEM_TS
> vpath % $(top_srcdir)/src/filesystem
> endif
>@@ -95,14 +96,16 @@ libstdc___la_LIBADD = \
> $(top_builddir)/libsupc++/libsupc++convenience.la \
> $(top_builddir)/src/c++98/libc++98convenience.la \
> $(top_builddir)/src/c++11/libc++11convenience.la \
>- $(top_builddir)/src/c++17/libc++17convenience.la
>+ $(top_builddir)/src/c++17/libc++17convenience.la \
>+ $(top_builddir)/src/c++20/libc++20convenience.la
>
> libstdc___la_DEPENDENCIES = \
> ${version_dep} \
> $(top_builddir)/libsupc++/libsupc++convenience.la \
> $(top_builddir)/src/c++98/libc++98convenience.la \
> $(top_builddir)/src/c++11/libc++11convenience.la \
>- $(top_builddir)/src/c++17/libc++17convenience.la
>+ $(top_builddir)/src/c++17/libc++17convenience.la \
>+ $(top_builddir)/src/c++20/libc++20convenience.la
>
> libstdc___la_LDFLAGS = \
> -version-info $(libtool_VERSION) ${version_arg} -lm
>@@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc
> # segregated in the sources with -D_GLIBCXX_SHARED.
> #
> # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
>-# only -prefer-pic objects are generated for the convenience libraries.
>+# src/c++20, only -prefer-pic objects are generated for the convenience
>+# libraries.
> #
> # In the main src directory, make shared and static objects just for
> # the compat libraries. Shared objects are compiled with -prefer-pic
>diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am
>new file mode 100644
>index 00000000000..423a79f3686
>--- /dev/null
>+++ b/libstdc++-v3/src/c++20/Makefile.am
>@@ -0,0 +1,105 @@
>+## Makefile for the C++20 sources of the GNU C++ Standard library.
>+##
>+## Copyright (C) 1997-2020 Free Software Foundation, Inc.
>+##
>+## This file is part of the libstdc++ version 3 distribution.
>+## Process this file with automake to produce Makefile.in.
>+
>+## This file is part of the GNU ISO C++ Library. This library is free
>+## software; you can redistribute it and/or modify it under the
>+## terms of the GNU General Public License as published by the
>+## Free Software Foundation; either version 3, or (at your option)
>+## any later version.
>+
>+## This library is distributed in the hope that it will be useful,
>+## but WITHOUT ANY WARRANTY; without even the implied warranty of
>+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+## GNU General Public License for more details.
>+
>+## You should have received a copy of the GNU General Public License along
>+## with this library; see the file COPYING3. If not see
>+## <http://www.gnu.org/licenses/>.
>+
>+include $(top_srcdir)/fragment.am
>+
>+# Convenience library for C++17 runtime.
>+noinst_LTLIBRARIES = libc++20convenience.la
>+
>+headers =
>+
>+if ENABLE_EXTERN_TEMPLATE
>+# XTEMPLATE_FLAGS = -fno-implicit-templates
>+inst_sources = \
>+ sstream-inst.cc
>+else
>+# XTEMPLATE_FLAGS =
>+inst_sources =
>+endif
>+
>+sources =
>+
>+vpath % $(top_srcdir)/src/c++20
>+
>+libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
>+
>+# AM_CXXFLAGS needs to be in each subdirectory so that it can be
>+# modified in a per-library or per-sub-library way. Need to manually
>+# set this option because CONFIG_CXXFLAGS has to be after
>+# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
>+# as the occasion calls for it.
>+AM_CXXFLAGS = \
>+ -std=gnu++20 \
>+ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
>+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
>+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
>+ -fimplicit-templates
>+
>+AM_MAKEFLAGS = \
>+ "gxx_include_dir=$(gxx_include_dir)"
>+
>+# Libtool notes
>+
>+# 1) In general, libtool expects an argument such as `--tag=CXX' when
>+# using the C++ compiler, because that will enable the settings
>+# detected when C++ support was being configured. However, when no
>+# such flag is given in the command line, libtool attempts to figure
>+# it out by matching the compiler name in each configuration section
>+# against a prefix of the command line. The problem is that, if the
>+# compiler name and its initial flags stored in the libtool
>+# configuration file don't match those in the command line, libtool
>+# can't decide which configuration to use, and it gives up. The
>+# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
>+# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
>+# attempt to infer which configuration to use.
>+#
>+# The second tag argument, `--tag disable-shared` means that libtool
>+# only compiles each source once, for static objects. In actuality,
>+# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
>+# the libtool command that is used create the object, which is
>+# suitable for shared libraries. The `--tag disable-shared` must be
>+# placed after --tag CXX lest things CXX undo the affect of
>+# disable-shared.
>+
>+# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
>+# last. (That way, things like -O2 passed down from the toplevel can
>+# be overridden by --enable-debug.)
>+LTCXXCOMPILE = \
>+ $(LIBTOOL) --tag CXX --tag disable-shared \
>+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
>+ --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
>+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
>+
>+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
>+
>+# 3) We'd have a problem when building the shared libstdc++ object if
>+# the rules automake generates would be used. We cannot allow g++ to
>+# be used since this would add -lstdc++ to the link line which of
>+# course is problematic at this point. So, we get the top-level
>+# directory to configure libstdc++-v3 to use gcc as the C++
>+# compilation driver.
>+CXXLINK = \
>+ $(LIBTOOL) --tag CXX --tag disable-shared \
>+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
>+ --mode=link $(CXX) \
>+ $(VTV_CXXLINKFLAGS) \
>+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
>diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in
>new file mode 100644
>index 00000000000..0e2de19ae59
>diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
>new file mode 100644
>index 00000000000..e04560d28c8
>--- /dev/null
>+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
>@@ -0,0 +1,108 @@
>+// Explicit instantiation file.
>+
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// Under Section 7 of GPL version 3, you are granted additional
>+// permissions described in the GCC Runtime Library Exception, version
>+// 3.1, as published by the Free Software Foundation.
>+
>+// You should have received a copy of the GNU General Public License and
>+// a copy of the GCC Runtime Library Exception along with this program;
>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>+// <http://www.gnu.org/licenses/>.
>+
>+//
>+// ISO C++ 14882:
>+//
>+
>+// Instantiations in this file are only for the new SSO std::string ABI
>+#include <sstream>
>+
>+namespace std _GLIBCXX_VISIBILITY(default)
>+{
>+_GLIBCXX_BEGIN_NAMESPACE_VERSION
>+
>+template basic_stringbuf<char>::basic_stringbuf(const allocator_type&);
>+template basic_stringbuf<char>::basic_stringbuf(ios_base::openmode,
>+ const allocator_type&);
>+template basic_stringbuf<char>::basic_stringbuf(__string_type&&,
>+ ios_base::openmode);
>+template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
>+ const allocator_type&);
>+template basic_stringbuf<char>::allocator_type
>+basic_stringbuf<char>::get_allocator() const noexcept;
>+template basic_stringbuf<char>::__sv_type
>+basic_stringbuf<char>::view() const noexcept;
>+
>+template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_istringstream<char>::basic_istringstream(__string_type&&,
>+ ios_base::openmode);
>+template string_view
>+basic_istringstream<char>::view() const noexcept;
>+
>+template basic_ostringstream<char>::basic_ostringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_ostringstream<char>::basic_ostringstream(__string_type&&,
>+ ios_base::openmode);
>+template string_view
>+basic_ostringstream<char>::view() const noexcept;
>+
>+template basic_stringstream<char>::basic_stringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_stringstream<char>::basic_stringstream(__string_type&&,
>+ ios_base::openmode);
>+template string_view
>+basic_stringstream<char>::view() const noexcept;
>+
>+#ifdef _GLIBCXX_USE_WCHAR_T
>+using wsv_type = basic_string_view<wchar_t>;
>+
>+template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
>+template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
>+ const allocator_type&);
>+template basic_stringbuf<wchar_t>::basic_stringbuf(__string_type&&,
>+ ios_base::openmode);
>+template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
>+ const allocator_type&);
>+template basic_stringbuf<wchar_t>::allocator_type
>+basic_stringbuf<wchar_t>::get_allocator() const noexcept;
>+
>+template basic_istringstream<wchar_t>::__stringbuf_type::__sv_type
>+basic_stringbuf<wchar_t>::view() const noexcept;
>+
>+template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_istringstream<wchar_t>::basic_istringstream(__string_type&&,
>+ ios_base::openmode);
>+template wstring_view
>+basic_istringstream<wchar_t>::view() const noexcept;
>+
>+template basic_ostringstream<wchar_t>::basic_ostringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_ostringstream<wchar_t>::basic_ostringstream(__string_type&&,
>+ ios_base::openmode);
>+template wstring_view
>+basic_ostringstream<wchar_t>::view() const noexcept;
>+
>+template basic_stringstream<wchar_t>::basic_stringstream(ios_base::openmode,
>+ const allocator_type&);
>+template basic_stringstream<wchar_t>::basic_stringstream(__string_type&&,
>+ ios_base::openmode);
>+template wstring_view
>+basic_stringstream<wchar_t>::view() const noexcept;
>+#endif
>+
>+_GLIBCXX_END_NAMESPACE_VERSION
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>new file mode 100644
>index 00000000000..496aa6963e0
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::istringstream::allocator_type a;
>+ std::istringstream stm(std::ios_base::in, a);
>+}
>+
>+auto const cstr = "This is a test";
>+
>+void
>+test02()
>+{
>+ std::string s1(cstr);
>+ std::istringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::string s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<char>;
>+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in;
>+ str_type s1(cstr);
>+
>+ {
>+ std::istringstream::allocator_type a;
>+ std::istringstream sbuf(s1, mode, a);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::istringstream sbuf(s1, mode);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::istringstream sbuf(s1);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
>new file mode 100644
>index 00000000000..26a3a86c46e
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::wistringstream::allocator_type a;
>+ std::wistringstream stm(std::ios_base::in, a);
>+}
>+
>+auto const cstr = L"This is a test";
>+
>+void
>+test02()
>+{
>+ std::wstring s1(cstr);
>+ std::wistringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::wstring s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
>+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in;
>+ str_type s1(cstr);
>+
>+ {
>+ std::wistringstream::allocator_type a;
>+ std::wistringstream sbuf(s1, mode, a);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wistringstream sbuf(s1, mode);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wistringstream sbuf(s1);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
>new file mode 100644
>index 00000000000..091de5f7a79
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::string s("This is a test");
>+ std::istringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
>new file mode 100644
>index 00000000000..f6599643bd9
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::wstring s(L"This is a test");
>+ std::wistringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
>new file mode 100644
>index 00000000000..cba69f80931
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::ostringstream::allocator_type a;
>+ std::ostringstream stm(std::ios_base::in, a);
>+}
>+
>+auto const cstr = "This is a test";
>+
>+void
>+test02()
>+{
>+ std::string s1(cstr);
>+ std::ostringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::string s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<char>;
>+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
>+
>+ auto const mode = std::ios_base::out;
>+ str_type s1(cstr);
>+
>+ {
>+ std::ostringstream::allocator_type a;
>+ std::ostringstream sbuf(s1, mode, a);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::ostringstream sbuf(s1, mode);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::ostringstream sbuf(s1);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
>new file mode 100644
>index 00000000000..9021186d2c8
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::wostringstream::allocator_type a;
>+ std::wostringstream stm(std::ios_base::out, a);
>+}
>+
>+auto const cstr = L"This is a test";
>+
>+void
>+test02()
>+{
>+ std::wstring s1(cstr);
>+ std::wostringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::wstring s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
>+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
>+
>+ auto const mode = std::ios_base::out;
>+ str_type s1(cstr);
>+
>+ {
>+ std::wostringstream::allocator_type a;
>+ std::wostringstream sbuf(s1, mode, a);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wostringstream sbuf(s1, mode);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wostringstream sbuf(s1);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
>new file mode 100644
>index 00000000000..a366363abb5
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::string s("This is a test");
>+ std::ostringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
>new file mode 100644
>index 00000000000..1ebf7c505e3
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::wstring s(L"This is a test");
>+ std::wostringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
>new file mode 100644
>index 00000000000..ce669358c85
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
>@@ -0,0 +1,121 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ {
>+ using alloc_type = __gnu_test::uneq_allocator<char>;
>+ using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
>+ alloc_type>;
>+
>+ alloc_type aa;
>+ sbuf_t sbuf1(aa);
>+ VERIFY( aa == sbuf1.get_allocator() );
>+
>+ alloc_type aaa(42);
>+ sbuf_t sbuf2(aaa);
>+ VERIFY( aaa == sbuf2.get_allocator() );
>+
>+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
>+ }
>+
>+ std::stringbuf::allocator_type a;
>+ {
>+ std::stringbuf sbuf(std::ios_base::in, a);
>+ }
>+
>+ {
>+ std::stringbuf sbuf(a);
>+ }
>+}
>+
>+auto const cstr = "This is a test";
>+
>+void
>+test02()
>+{
>+ std::string s1(cstr);
>+ std::stringbuf sbuf(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<char>;
>+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in | std::ios_base::out;
>+ str_type s1(cstr);
>+
>+ {
>+ std::stringbuf::allocator_type a;
>+ std::stringbuf sbuf(s1, mode, a);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::stringbuf sbuf(s1, mode);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::stringbuf sbuf(s1);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+void
>+test04()
>+{
>+ std::stringbuf sbuf1(cstr);
>+
>+ std::stringbuf::allocator_type a;
>+ std::stringbuf sbuf2(std::move(sbuf1), a);
>+ VERIFY( sbuf1.str().empty() );
>+
>+ std::string s(cstr);
>+ VERIFY( sbuf2.str() == s );
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ test04();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
>new file mode 100644
>index 00000000000..e05acc42165
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
>@@ -0,0 +1,105 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::wstringbuf::allocator_type a;
>+ {
>+ std::wstringbuf sbuf(std::ios_base::in, a);
>+ }
>+
>+ {
>+ std::wstringbuf sbuf(a);
>+ }
>+}
>+
>+auto const cstr = L"This is a test";
>+
>+void
>+test02()
>+{
>+ std::wstring s1(cstr);
>+ std::wstringbuf sbuf(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
>+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in | std::ios_base::out;
>+ str_type s1(cstr);
>+
>+ {
>+ std::wstringbuf::allocator_type a;
>+ std::wstringbuf sbuf(s1, mode, a);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wstringbuf sbuf(s1, mode);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wstringbuf sbuf(s1);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+void
>+test04()
>+{
>+ std::wstringbuf sbuf1(cstr);
>+
>+ std::wstringbuf::allocator_type a;
>+ std::wstringbuf sbuf2(std::move(sbuf1), a);
>+ VERIFY( sbuf1.str().empty() );
>+
>+ std::wstring s(cstr);
>+ VERIFY( sbuf2.str() == s );
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ test04();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
>new file mode 100644
>index 00000000000..8f8c62daa21
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::string s("This is a test");
>+ std::stringbuf sbuf(s);
>+ VERIFY( sbuf.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
>new file mode 100644
>index 00000000000..0d23d7d8e66
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::wstring s(L"This is a test");
>+ std::wstringbuf sbuf(s);
>+ VERIFY( sbuf.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
>new file mode 100644
>index 00000000000..83a3374b3cd
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::stringstream::allocator_type a;
>+ std::stringstream stm(std::ios_base::in, a);
>+}
>+
>+auto const cstr = "This is a test";
>+
>+void
>+test02()
>+{
>+ std::string s1(cstr);
>+ std::stringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::string s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<char>;
>+ using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in | std::ios_base::out;
>+ str_type s1(cstr);
>+
>+ {
>+ std::stringstream::allocator_type a;
>+ std::stringstream sbuf(s1, mode, a);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::stringstream sbuf(s1, mode);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::stringstream sbuf(s1);
>+ std::string s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
>new file mode 100644
>index 00000000000..26a3a86c46e
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
>@@ -0,0 +1,85 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ std::wistringstream::allocator_type a;
>+ std::wistringstream stm(std::ios_base::in, a);
>+}
>+
>+auto const cstr = L"This is a test";
>+
>+void
>+test02()
>+{
>+ std::wstring s1(cstr);
>+ std::wistringstream stm(std::move(s1));
>+ VERIFY( s1.empty() );
>+
>+ std::wstring s2(cstr);
>+ VERIFY( stm.str() == s2 );
>+}
>+
>+void
>+test03()
>+{
>+ using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
>+ using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
>+
>+ auto const mode = std::ios_base::in;
>+ str_type s1(cstr);
>+
>+ {
>+ std::wistringstream::allocator_type a;
>+ std::wistringstream sbuf(s1, mode, a);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wistringstream sbuf(s1, mode);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+
>+ {
>+ std::wistringstream sbuf(s1);
>+ std::wstring s2(cstr);
>+ VERIFY( sbuf.str() == s2 );
>+ }
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+ test02();
>+ test03();
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
>new file mode 100644
>index 00000000000..f47035cf148
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::string s("This is a test");
>+ std::stringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
>new file mode 100644
>index 00000000000..d707cfed243
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc
>@@ -0,0 +1,35 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+// { dg-require-effective-target cxx11-abi }
>+
>+#include <sstream>
>+#include <string_view>
>+#include <testsuite_hooks.h>
>+
>+int
>+main()
>+{
>+ std::wstring s(L"This is a test");
>+ std::wstringstream stm(s);
>+ VERIFY( stm.view() == s );
>+ return 0;
>+}
>--
>2.26.2
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-26 21:09 ` Jonathan Wakely
@ 2020-10-28 23:59 ` Jonathan Wakely
2020-10-29 1:30 ` Jonathan Wakely
2020-10-29 20:06 ` Rainer Orth
0 siblings, 2 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-28 23:59 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, trodgers
[-- Attachment #1: Type: text/plain, Size: 2967 bytes --]
On 26/10/20 21:09 +0000, Jonathan Wakely wrote:
>On 26/10/20 13:47 -0700, Thomas Rodgers wrote:
>>From: Thomas Rodgers <trodgers@redhat.com>
>>
>>New ctors and ::view() accessor for -
>> * basic_stingbuf
>> * basic_istringstream
>> * basic_ostringstream
>> * basic_stringstreamm
>>
>>New ::get_allocator() accessor for basic_stringbuf.
>>
>>libstdc++-v3/ChangeLog:
>> * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
>> * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
>> basic_stringbuf::basic_stringbuf(allocator const&),
>> basic_stringbuf::basic_stringbuf(openmode, allocator const&),
>> basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
>> basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
>> basic_stringbuf::get_allocator(),
>> basic_stringbuf::view(),
>> basic_istringstream::basic_istringstream(basic_string&&, openmode),
>> basic_istringstream::basic_istringstream(openmode, allocator const&),
>> basic_istringstream::view(),
>> basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
>> basic_ostringstream::basic_ostringstream(openmode, allocator const&),
>> basic_ostringstream::view(),
>> basic_stringstream::basic_stringstream(basic_string&&, openmode),
>> basic_stringstream::basic_stringstream(openmode, allocator const&),
>> basic_stringstream::view().
>
>As discussed on IRC< please don't name every one of these functions
>for the linker script changes, it's just redundant noise. They're
>already listed below in the include/std/sstream changes.
>
>Look at past changelog entries for the gnu.ver file.
>
>> * configure: Regenerate.
>> * include/std/sstream:
>> (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
>> (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
>> (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
>> (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
>
>New line before the Likewise.
>
>
>There are a few formatting changes mentioned below. OK for trunk with
>those changes. Thanks. Go ahead and commit the <syncstream> patch
>after this one too.
The patch that was committed broke the linker script. The attached
patch restores the piece that got lost, and removes the duplicate
patterns added for the new symbols. Pushed to trunk.
This fixes all the failures related to exception_ptr. I'm still seeing
four new failures which weren't there before:
FAIL: 24_iterators/istream_iterator/sentinel.cc execution test
FAIL: 24_iterators/istreambuf_iterator/sentinel.cc execution test
FAIL: 27_io/basic_istream/extractors_character/char/lwg2499.cc execution test
FAIL: std/ranges/istream_view.cc execution test
I'm not sure what's happening there. It looks like some symbols I
added recently are not present now. I'm investigating.
Also, it looks like the get_allocator() members of the streams are not
exported (only basic_stringbuf::get_allocator() is).
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4591 bytes --]
commit f4f9364d2074e027490c1b08956ac1cbd9617575
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Oct 28 23:10:21 2020
libstdc++: Fix linker script
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Remove duplicate
patterns.
(CXXABI_1.3.13): Restore missing piece.
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 2648c813616..80994b203df 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2335,51 +2335,6 @@ GLIBCXX_3.4.29 {
# std::__throw_bad_array_new_length()
_ZSt28__throw_bad_array_new_lengthv;
- # basic_stringbuf::basic_stringbuf(allocator const&)
- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
-
- # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
-
- # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
-
- # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
-
- # basic_stringbuf::get_allocator()
- _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
-
- # basic_stringbuf::view()
- _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
-
- # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
- _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
-
- # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
- _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
-
- # basic_istringstream::view()
- _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
-
- # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
- _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
-
- # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
- _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
-
- # basic_ostringstream::view()
- _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
-
- # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
- _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
-
- # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
- _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
-
- # basic_stringstream::view()
- _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
-
# basic_stringbuf::basic_stringbuf(allocator const&)
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ERKS3_;
@@ -2398,13 +2353,13 @@ GLIBCXX_3.4.29 {
# basic_stringbuf::view()
_ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
- # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
+ # basic_[io]stringstream::basic_[io]stringstream(basic_string&&, ios_base::openmode)
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
# basic_[io]stringstream::basic_[io]stringstream(ios_base::openmode, allocator const&)
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ESt13_Ios_OpenmodeRKS3_;
- # basic_istringstream::view()
+ # basic_[io]stringstream::view()
_ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
# basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
@@ -2716,6 +2671,15 @@ CXXABI_1.3.12 {
} CXXABI_1.3.11;
+CXXABI_1.3.13 {
+
+ # std::exception_ptr::_M_addref()
+ _ZNSt15__exception_ptr13exception_ptr9_M_addrefEv;
+ # std::exception_ptr::_M_release()
+ _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv;
+
+} CXXABI_1.3.12;
+
# Symbols in the support library (libsupc++) supporting transactional memory.
CXXABI_TM_1 {
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-28 23:59 ` Jonathan Wakely
@ 2020-10-29 1:30 ` Jonathan Wakely
2020-10-29 20:06 ` Rainer Orth
1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-29 1:30 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, trodgers
[-- Attachment #1: Type: text/plain, Size: 7860 bytes --]
On 28/10/20 23:59 +0000, Jonathan Wakely wrote:
>On 26/10/20 21:09 +0000, Jonathan Wakely wrote:
>>On 26/10/20 13:47 -0700, Thomas Rodgers wrote:
>>>From: Thomas Rodgers <trodgers@redhat.com>
>>>
>>>New ctors and ::view() accessor for -
>>>* basic_stingbuf
>>>* basic_istringstream
>>>* basic_ostringstream
>>>* basic_stringstreamm
>>>
>>>New ::get_allocator() accessor for basic_stringbuf.
>>>
>>>libstdc++-v3/ChangeLog:
>>> * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
>>> * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
>>> basic_stringbuf::basic_stringbuf(allocator const&),
>>> basic_stringbuf::basic_stringbuf(openmode, allocator const&),
>>> basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
>>> basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
>>> basic_stringbuf::get_allocator(),
>>> basic_stringbuf::view(),
>>> basic_istringstream::basic_istringstream(basic_string&&, openmode),
>>> basic_istringstream::basic_istringstream(openmode, allocator const&),
>>> basic_istringstream::view(),
>>> basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
>>> basic_ostringstream::basic_ostringstream(openmode, allocator const&),
>>> basic_ostringstream::view(),
>>> basic_stringstream::basic_stringstream(basic_string&&, openmode),
>>> basic_stringstream::basic_stringstream(openmode, allocator const&),
>>> basic_stringstream::view().
>>
>>As discussed on IRC< please don't name every one of these functions
>>for the linker script changes, it's just redundant noise. They're
>>already listed below in the include/std/sstream changes.
>>
>>Look at past changelog entries for the gnu.ver file.
>>
>>> * configure: Regenerate.
>>> * include/std/sstream:
>>> (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
>>> (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
>>> (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
>>> (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise.
>>
>>New line before the Likewise.
>>
>>
>>There are a few formatting changes mentioned below. OK for trunk with
>>those changes. Thanks. Go ahead and commit the <syncstream> patch
>>after this one too.
>
>The patch that was committed broke the linker script. The attached
>patch restores the piece that got lost, and removes the duplicate
>patterns added for the new symbols. Pushed to trunk.
>
>This fixes all the failures related to exception_ptr. I'm still seeing
>four new failures which weren't there before:
>
>FAIL: 24_iterators/istream_iterator/sentinel.cc execution test
>FAIL: 24_iterators/istreambuf_iterator/sentinel.cc execution test
>FAIL: 27_io/basic_istream/extractors_character/char/lwg2499.cc execution test
>FAIL: std/ranges/istream_view.cc execution test
>
>I'm not sure what's happening there. It looks like some symbols I
>added recently are not present now. I'm investigating.
The attached patch fixes the failing tests. Not fully tested, but
pushed to trunk.
>Also, it looks like the get_allocator() members of the streams are not
>exported (only basic_stringbuf::get_allocator() is).
>
>
>commit f4f9364d2074e027490c1b08956ac1cbd9617575
>Author: Jonathan Wakely <jwakely@redhat.com>
>Date: Wed Oct 28 23:10:21 2020
>
> libstdc++: Fix linker script
>
> libstdc++-v3/ChangeLog:
>
> * config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Remove duplicate
> patterns.
> (CXXABI_1.3.13): Restore missing piece.
>
>diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
>index 2648c813616..80994b203df 100644
>--- a/libstdc++-v3/config/abi/pre/gnu.ver
>+++ b/libstdc++-v3/config/abi/pre/gnu.ver
>@@ -2335,51 +2335,6 @@ GLIBCXX_3.4.29 {
> # std::__throw_bad_array_new_length()
> _ZSt28__throw_bad_array_new_lengthv;
>
>- # basic_stringbuf::basic_stringbuf(allocator const&)
>- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;
>-
>- # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&)
>- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3;
>-
>- # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode)
>- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>-
>- # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)
>- _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaIcEEC1EOS4_RKS3_;
>-
>- # basic_stringbuf::get_allocator()
>- _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv;
>-
>- # basic_stringbuf::view()
>- _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>-
>- # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
>- _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>-
>- # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&)
>- _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ESt13_Ios_OpenmodeRKS3_;
>-
>- # basic_istringstream::view()
>- _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>-
>- # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode)
>- _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>-
>- # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&)
>- _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
>-
>- # basic_ostringstream::view()
>- _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>-
>- # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
>- _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>-
>- # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&)
>- _ZNSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaIcEEC1ESt13_Ios_OpenmodeRKS3_;
>-
>- # basic_stringstream::view()
>- _ZNKSt7__cxx1119basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>-
> # basic_stringbuf::basic_stringbuf(allocator const&)
> _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ERKS3_;
>
>@@ -2398,13 +2353,13 @@ GLIBCXX_3.4.29 {
> # basic_stringbuf::view()
> _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>
>- # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode)
>+ # basic_[io]stringstream::basic_[io]stringstream(basic_string&&, ios_base::openmode)
> _ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]EONS_12basic_stringI[cw]S2_S3_EESt13_Ios_Openmode;
>
> # basic_[io]stringstream::basic_[io]stringstream(ios_base::openmode, allocator const&)
> _ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ESt13_Ios_OpenmodeRKS3_;
>
>- # basic_istringstream::view()
>+ # basic_[io]stringstream::view()
> _ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv;
>
> # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode)
>@@ -2716,6 +2671,15 @@ CXXABI_1.3.12 {
>
> } CXXABI_1.3.11;
>
>+CXXABI_1.3.13 {
>+
>+ # std::exception_ptr::_M_addref()
>+ _ZNSt15__exception_ptr13exception_ptr9_M_addrefEv;
>+ # std::exception_ptr::_M_release()
>+ _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv;
>+
>+} CXXABI_1.3.12;
>+
> # Symbols in the support library (libsupc++) supporting transactional memory.
> CXXABI_TM_1 {
>
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1065 bytes --]
commit c6bfc4eb3c961181912647781d7dd38057db655b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Oct 29 01:05:03 2020
libstdc++: Fix new basic_stringbuf constructor
libstdc++-v3/ChangeLog:
* include/std/sstream (basic_stringbuf(__string_type&&, openmode)):
Call _M_init_syncbuf to set up get/put areas. Also qualify
std::move.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index f03f3abd6fc..33a00486606 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -181,8 +181,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
basic_stringbuf(__string_type&& __s,
ios_base::openmode __mode = ios_base::in
| ios_base::out )
- : __streambuf_type(), _M_mode(__mode), _M_string(move(__s))
- { }
+ : __streambuf_type(), _M_mode(__mode), _M_string(std::move(__s))
+ { _M_stringbuf_init(__mode); }
template<typename _SAlloc>
basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-28 23:59 ` Jonathan Wakely
2020-10-29 1:30 ` Jonathan Wakely
@ 2020-10-29 20:06 ` Rainer Orth
2020-10-29 21:41 ` Jonathan Wakely
1 sibling, 1 reply; 20+ messages in thread
From: Rainer Orth @ 2020-10-29 20:06 UTC (permalink / raw)
To: Jonathan Wakely via Gcc-patches
Cc: Thomas Rodgers, Jonathan Wakely, trodgers, libstdc++
[-- Attachment #1: Type: text/plain, Size: 4351 bytes --]
Hi Jonathan,
> On > The patch that was committed broke the linker script. The attached
> patch restores the piece that got lost, and removes the duplicate
> patterns added for the new symbols. Pushed to trunk.
even this fixed version broke Solaris bootstrap:
ld: fatal: libstdc++-symbols.ver-sun: 7318: symbol '_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 7319: symbol '_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv': symbol version conflict
matched by
##_ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE13get_allocatorEv (glob)
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv;
and
##_ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE[0-35-9]* (glob)
which matches
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv;
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE3strEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE3strEv;
ld: fatal: libstdc++-symbols.ver-sun: 7321: symbol '_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE4viewEv': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 7322: symbol '_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE4viewEv': symbol version conflict
matched by
##_ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv (glob)
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE4viewEv;
and
##_ZNKSt7__cxx1115basic_stringbuf* (glob)
which matches
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv;
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE3strEv;
_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE3strEv;
_ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE4viewEv;
ld: fatal: libstdc++-symbols.ver-sun: 7342: symbol '_ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE4viewEv': symbol version conflict
ld: fatal: libstdc++-symbols.ver-sun: 7343: symbol '_ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE4viewEv': symbol version conflict
matched by
##_ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4viewEv (glob)
_ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE4viewEv;
_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE4viewEv;
and
##_ZNKSt7__cxx1119basic_istringstream* (glob)
##_ZNKSt7__cxx1119basic_ostringstream* (glob)
which match
_ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE3strEv;
_ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE5rdbufEv;
_ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE3strEv;
_ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE4viewEv;
_ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE5rdbufEv;
_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv;
_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE4viewEv;
_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE5rdbufEv;
_ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE3strEv;
_ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE4viewEv;
_ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE5rdbufEv;
Tightening the patterns as in the attached patch at least allows
libstdc++.so.6 to link on i386-pc-solaris2.11; full bootstrap still
running. However, I can't tell if this is really correct.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gv.patch --]
[-- Type: text/x-patch, Size: 1173 bytes --]
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1791,11 +1791,11 @@ GLIBCXX_3.4.21 {
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ESt13_Ios_Openmode;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EED[012]Ev;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[a34]*;
- _ZNKSt7__cxx1115basic_stringbuf*;
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE[0235-9]*;
_ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
_ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE5rdbufEv;
- _ZNKSt7__cxx1119basic_istringstream*;
- _ZNKSt7__cxx1119basic_ostringstream*;
+ _ZNKSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[0-35-9]*;
+ _ZNKSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[0-35-9]*;
_ZT[ISTV]NSt7__cxx1115basic_stringbuf*;
_ZT[ISTV]NSt7__cxx1118basic_stringstream*;
_ZT[ISTV]NSt7__cxx1119basic_istringstream*;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-29 20:06 ` Rainer Orth
@ 2020-10-29 21:41 ` Jonathan Wakely
2020-10-29 22:51 ` Jonathan Wakely
2020-10-30 12:39 ` Rainer Orth
0 siblings, 2 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-29 21:41 UTC (permalink / raw)
To: Rainer Orth; +Cc: Gcc-patches, trodgers, libstdc++
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
On 29/10/20 21:06 +0100, Rainer Orth wrote:
>Tightening the patterns as in the attached patch at least allows
>libstdc++.so.6 to link on i386-pc-solaris2.11; full bootstrap still
>running. However, I can't tell if this is really correct.
I think we want this attached patch instead. It tightens them up to
exactly the symbols we actually need to export and no more. This will
avoid needing to tighten them again in the near future when the new
overloads of str() are added.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1210 bytes --]
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 80994b203df..4dddfd3d263 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1791,11 +1791,11 @@ GLIBCXX_3.4.21 {
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ESt13_Ios_Openmode;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EED[012]Ev;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[a34]*;
- _ZNKSt7__cxx1115basic_stringbuf*;
+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
_ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
_ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE5rdbufEv;
- _ZNKSt7__cxx1119basic_istringstream*;
- _ZNKSt7__cxx1119basic_ostringstream*;
+ _ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
+ _ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE5rdbufEv;
_ZT[ISTV]NSt7__cxx1115basic_stringbuf*;
_ZT[ISTV]NSt7__cxx1118basic_stringstream*;
_ZT[ISTV]NSt7__cxx1119basic_istringstream*;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-29 21:41 ` Jonathan Wakely
@ 2020-10-29 22:51 ` Jonathan Wakely
2020-10-30 12:39 ` Rainer Orth
1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-10-29 22:51 UTC (permalink / raw)
To: Rainer Orth; +Cc: Gcc-patches, trodgers, libstdc++
On 29/10/20 21:41 +0000, Jonathan Wakely wrote:
>On 29/10/20 21:06 +0100, Rainer Orth wrote:
>>Tightening the patterns as in the attached patch at least allows
>>libstdc++.so.6 to link on i386-pc-solaris2.11; full bootstrap still
>>running. However, I can't tell if this is really correct.
>
>I think we want this attached patch instead. It tightens them up to
>exactly the symbols we actually need to export and no more. This will
>avoid needing to tighten them again in the near future when the new
>overloads of str() are added.
>
>
>diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
>index 80994b203df..4dddfd3d263 100644
>--- a/libstdc++-v3/config/abi/pre/gnu.ver
>+++ b/libstdc++-v3/config/abi/pre/gnu.ver
>@@ -1791,11 +1791,11 @@ GLIBCXX_3.4.21 {
> _ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ESt13_Ios_Openmode;
> _ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EED[012]Ev;
> _ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[a34]*;
>- _ZNKSt7__cxx1115basic_stringbuf*;
>+ _ZNKSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
> _ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
> _ZNKSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE5rdbufEv;
>- _ZNKSt7__cxx1119basic_istringstream*;
>- _ZNKSt7__cxx1119basic_ostringstream*;
>+ _ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
>+ _ZNKSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE5rdbufEv;
> _ZT[ISTV]NSt7__cxx1115basic_stringbuf*;
> _ZT[ISTV]NSt7__cxx1118basic_stringstream*;
> _ZT[ISTV]NSt7__cxx1119basic_istringstream*;
Pushed to trunk now.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-29 21:41 ` Jonathan Wakely
2020-10-29 22:51 ` Jonathan Wakely
@ 2020-10-30 12:39 ` Rainer Orth
1 sibling, 0 replies; 20+ messages in thread
From: Rainer Orth @ 2020-10-30 12:39 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Gcc-patches, trodgers, libstdc++
Hi Jonathan,
> On 29/10/20 21:06 +0100, Rainer Orth wrote:
>>Tightening the patterns as in the attached patch at least allows
>>libstdc++.so.6 to link on i386-pc-solaris2.11; full bootstrap still
>>running. However, I can't tell if this is really correct.
>
> I think we want this attached patch instead. It tightens them up to
> exactly the symbols we actually need to export and no more. This will
> avoid needing to tighten them again in the near future when the new
> overloads of str() are added.
that's even better of course.
Thanks.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-10-07 16:55 [PATCH] libstdc++: Implement C++20 features for <sstream> Thomas Rodgers
2020-10-07 19:44 ` Jonathan Wakely
@ 2020-11-04 19:54 ` Stephan Bergmann
2020-11-04 20:43 ` Thomas Rodgers
1 sibling, 1 reply; 20+ messages in thread
From: Stephan Bergmann @ 2020-11-04 19:54 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: trodgers, gcc-patches, libstdc++
On 07/10/2020 18:55, Thomas Rodgers wrote:
> From: Thomas Rodgers <trodgers@redhat.com>
>
> New ctors and ::view() accessor for -
> * basic_stingbuf
> * basic_istringstream
> * basic_ostringstream
> * basic_stringstreamm
>
> New ::get_allocator() accessor for basic_stringbuf.
I found that this
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d>
"libstdc++: Implement C++20 features for <sstream>" changed the behavior of
> $ cat test.cc
> #include <iostream>
> #include <iterator>
> #include <sstream>
> int main() {
> std::stringstream s("a");
> std::istreambuf_iterator<char> i(s);
> if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
> }
>
> $ g++ -std=c++20 test.cc
> $ ./a.out
from printing "a" to printing nothing. (The `i != ...` comparison
appears to change i from pointing at "a" to pointing to null, and
returns false.)
I ran into this when building LibreOffice, and I hope test.cc is a
faithfully minimized reproducer. However, I know little about
std::istreambuf_iterator, so it may well be that the code isn't even valid.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-11-04 19:54 ` Stephan Bergmann
@ 2020-11-04 20:43 ` Thomas Rodgers
2020-11-04 21:45 ` Jonathan Wakely
0 siblings, 1 reply; 20+ messages in thread
From: Thomas Rodgers @ 2020-11-04 20:43 UTC (permalink / raw)
To: Stephan Bergmann; +Cc: Thomas Rodgers, gcc-patches, libstdc++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97719
> On Nov 4, 2020, at 11:54 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
>
> On 07/10/2020 18:55, Thomas Rodgers wrote:
>> From: Thomas Rodgers <trodgers@redhat.com>
>> New ctors and ::view() accessor for -
>> * basic_stingbuf
>> * basic_istringstream
>> * basic_ostringstream
>> * basic_stringstreamm
>> New ::get_allocator() accessor for basic_stringbuf.
> I found that this <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d> "libstdc++: Implement C++20 features for <sstream>" changed the behavior of
>
>> $ cat test.cc
>> #include <iostream>
>> #include <iterator>
>> #include <sstream>
>> int main() {
>> std::stringstream s("a");
>> std::istreambuf_iterator<char> i(s);
>> if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
>> }
>> $ g++ -std=c++20 test.cc
>> $ ./a.out
>
> from printing "a" to printing nothing. (The `i != ...` comparison appears to change i from pointing at "a" to pointing to null, and returns false.)
>
> I ran into this when building LibreOffice, and I hope test.cc is a faithfully minimized reproducer. However, I know little about std::istreambuf_iterator, so it may well be that the code isn't even valid.
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-11-04 20:43 ` Thomas Rodgers
@ 2020-11-04 21:45 ` Jonathan Wakely
2020-11-04 23:41 ` Jonathan Wakely
0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2020-11-04 21:45 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: Stephan Bergmann, Thomas Rodgers, libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]
On 04/11/20 12:43 -0800, Thomas Rodgers wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97719
>
>> On Nov 4, 2020, at 11:54 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
>>
>> On 07/10/2020 18:55, Thomas Rodgers wrote:
>>> From: Thomas Rodgers <trodgers@redhat.com>
>>> New ctors and ::view() accessor for -
>>> * basic_stingbuf
>>> * basic_istringstream
>>> * basic_ostringstream
>>> * basic_stringstreamm
>>> New ::get_allocator() accessor for basic_stringbuf.
>> I found that this <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d> "libstdc++: Implement C++20 features for <sstream>" changed the behavior of
>>
>>> $ cat test.cc
>>> #include <iostream>
>>> #include <iterator>
>>> #include <sstream>
>>> int main() {
>>> std::stringstream s("a");
>>> std::istreambuf_iterator<char> i(s);
>>> if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
>>> }
>>> $ g++ -std=c++20 test.cc
>>> $ ./a.out
>>
>> from printing "a" to printing nothing. (The `i != ...` comparison appears to change i from pointing at "a" to pointing to null, and returns false.)
>>
>> I ran into this when building LibreOffice, and I hope test.cc is a faithfully minimized reproducer. However, I know little about std::istreambuf_iterator, so it may well be that the code isn't even valid.
>>
I'm testing this patch.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2550 bytes --]
commit 1ca2fe0fc85403c6ea4e0775b5da051ff0eebc96
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Nov 4 21:44:05 2020
libstdc++: Fix default mode of new basic_stringstream constructor [PR 97719]
libstdc++-v3/ChangeLog:
PR libstdc++/97719
* include/std/sstream (basic_stringstream(string_type&&, openmode)):
Fix default argument.
* testsuite/27_io/basic_stringstream/cons/char/97719.cc: New test.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 33a00486606c..8acf1eb259ab 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -976,7 +976,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
explicit
basic_stringstream(__string_type&& __str,
- ios_base::openmode __mode = ios_base::out
+ ios_base::openmode __mode = ios_base::in
| ios_base::out)
: __iostream_type(), _M_stringbuf(std::move(__str), __mode)
{ this->init(std::__addressof(_M_stringbuf)); }
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc
new file mode 100644
index 000000000000..fa523a803b6d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <sstream>
+#include <iterator>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ // PR libstdc++/97719
+ std::string str = "a";
+ std::stringstream s(std::move(str));
+ std::istreambuf_iterator<char> i(s);
+ VERIFY( i != std::istreambuf_iterator<char>() );
+ VERIFY( *i == 'a' );
+}
+
+int
+main()
+{
+ test01();
+}
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-11-04 21:45 ` Jonathan Wakely
@ 2020-11-04 23:41 ` Jonathan Wakely
2020-11-05 13:33 ` Jonathan Wakely
0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Wakely @ 2020-11-04 23:41 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: Stephan Bergmann, Thomas Rodgers, libstdc++, gcc-patches
On 04/11/20 21:45 +0000, Jonathan Wakely wrote:
>On 04/11/20 12:43 -0800, Thomas Rodgers wrote:
>>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97719
>>
>>>On Nov 4, 2020, at 11:54 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
>>>
>>>On 07/10/2020 18:55, Thomas Rodgers wrote:
>>>>From: Thomas Rodgers <trodgers@redhat.com>
>>>>New ctors and ::view() accessor for -
>>>> * basic_stingbuf
>>>> * basic_istringstream
>>>> * basic_ostringstream
>>>> * basic_stringstreamm
>>>>New ::get_allocator() accessor for basic_stringbuf.
>>>I found that this <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d> "libstdc++: Implement C++20 features for <sstream>" changed the behavior of
>>>
>>>>$ cat test.cc
>>>>#include <iostream>
>>>>#include <iterator>
>>>>#include <sstream>
>>>>int main() {
>>>> std::stringstream s("a");
>>>> std::istreambuf_iterator<char> i(s);
>>>> if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
>>>>}
>>>>$ g++ -std=c++20 test.cc
>>>>$ ./a.out
>>>
>>>from printing "a" to printing nothing. (The `i != ...` comparison appears to change i from pointing at "a" to pointing to null, and returns false.)
>>>
>>>I ran into this when building LibreOffice, and I hope test.cc is a faithfully minimized reproducer. However, I know little about std::istreambuf_iterator, so it may well be that the code isn't even valid.
>>>
>
>I'm testing this patch.
Tested powerpc64le-linux. Pushed now.
>commit 1ca2fe0fc85403c6ea4e0775b5da051ff0eebc96
>Author: Jonathan Wakely <jwakely@redhat.com>
>Date: Wed Nov 4 21:44:05 2020
>
> libstdc++: Fix default mode of new basic_stringstream constructor [PR 97719]
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/97719
> * include/std/sstream (basic_stringstream(string_type&&, openmode)):
> Fix default argument.
> * testsuite/27_io/basic_stringstream/cons/char/97719.cc: New test.
>
>diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
>index 33a00486606c..8acf1eb259ab 100644
>--- a/libstdc++-v3/include/std/sstream
>+++ b/libstdc++-v3/include/std/sstream
>@@ -976,7 +976,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
>
> explicit
> basic_stringstream(__string_type&& __str,
>- ios_base::openmode __mode = ios_base::out
>+ ios_base::openmode __mode = ios_base::in
> | ios_base::out)
> : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
> { this->init(std::__addressof(_M_stringbuf)); }
>diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc
>new file mode 100644
>index 000000000000..fa523a803b6d
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/97719.cc
>@@ -0,0 +1,40 @@
>+// Copyright (C) 2020 Free Software Foundation, Inc.
>+//
>+// This file is part of the GNU ISO C++ Library. This library is free
>+// software; you can redistribute it and/or modify it under the
>+// terms of the GNU General Public License as published by the
>+// Free Software Foundation; either version 3, or (at your option)
>+// any later version.
>+
>+// This library is distributed in the hope that it will be useful,
>+// but WITHOUT ANY WARRANTY; without even the implied warranty of
>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+// GNU General Public License for more details.
>+
>+// You should have received a copy of the GNU General Public License along
>+// with this library; see the file COPYING3. If not see
>+// <http://www.gnu.org/licenses/>.
>+
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do run { target c++2a } }
>+
>+#include <sstream>
>+#include <iterator>
>+#include <testsuite_hooks.h>
>+
>+void
>+test01()
>+{
>+ // PR libstdc++/97719
>+ std::string str = "a";
>+ std::stringstream s(std::move(str));
>+ std::istreambuf_iterator<char> i(s);
>+ VERIFY( i != std::istreambuf_iterator<char>() );
>+ VERIFY( *i == 'a' );
>+}
>+
>+int
>+main()
>+{
>+ test01();
>+}
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] libstdc++: Implement C++20 features for <sstream>
2020-11-04 23:41 ` Jonathan Wakely
@ 2020-11-05 13:33 ` Jonathan Wakely
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Wakely @ 2020-11-05 13:33 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: Stephan Bergmann, Thomas Rodgers, libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]
On 04/11/20 23:41 +0000, Jonathan Wakely wrote:
>On 04/11/20 21:45 +0000, Jonathan Wakely wrote:
>>On 04/11/20 12:43 -0800, Thomas Rodgers wrote:
>>>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97719
>>>
>>>>On Nov 4, 2020, at 11:54 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
>>>>
>>>>On 07/10/2020 18:55, Thomas Rodgers wrote:
>>>>>From: Thomas Rodgers <trodgers@redhat.com>
>>>>>New ctors and ::view() accessor for -
>>>>> * basic_stingbuf
>>>>> * basic_istringstream
>>>>> * basic_ostringstream
>>>>> * basic_stringstreamm
>>>>>New ::get_allocator() accessor for basic_stringbuf.
>>>>I found that this <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d> "libstdc++: Implement C++20 features for <sstream>" changed the behavior of
>>>>
>>>>>$ cat test.cc
>>>>>#include <iostream>
>>>>>#include <iterator>
>>>>>#include <sstream>
>>>>>int main() {
>>>>>std::stringstream s("a");
>>>>>std::istreambuf_iterator<char> i(s);
>>>>>if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
>>>>>}
>>>>>$ g++ -std=c++20 test.cc
>>>>>$ ./a.out
>>>>
>>>>from printing "a" to printing nothing. (The `i != ...` comparison appears to change i from pointing at "a" to pointing to null, and returns false.)
>>>>
>>>>I ran into this when building LibreOffice, and I hope test.cc is a faithfully minimized reproducer. However, I know little about std::istreambuf_iterator, so it may well be that the code isn't even valid.
>>>>
>>
>>I'm testing this patch.
>
>Tested powerpc64le-linux. Pushed now.
And this fixes some other bugs in the new constructors.
Tested powerpc64le-linux, pushed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 28691 bytes --]
commit 432258be4f2cf4f0970f106db319e3dbab4ab13d
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Nov 5 12:16:13 2020
libstdc++: Fix new <sstream> constructors
- Add a missing 'explicit' to a basic_stringbuf constructor.
- Set up the get/put area pointers in the constructor from strings using
different allocator types.
- Remove public basic_stringbuf::__sv_type alias.
- Do not construct temporary basic_string objects with a
default-constructed allocator.
Also, change which basic_string constructor is used, as a minor
compile-time optimization. Constructing from a basic_string_view
requires more work from the compiler, so just use a pointer and length.
libstdc++-v3/ChangeLog:
* include/std/sstream (basic_stringbuf(const allocator_type&):
Add explicit.
(basic_stringbuf(const basic_string<C,T,SA>&, openmode, const A&)):
Call _M_stringbuf_init. Construct _M_string from pointer and length
to avoid constraint checks for string view.
(basic_stringbuf::view()): Make __sv_type alias local to the
function.
(basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&)):
Pass string to _M_streambuf instead of constructing a temporary
with the wrong allocator.
(basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&)):
Likewise.
(basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&)):
Likewise.
* src/c++20/sstream-inst.cc: Use string_view and wstring_view
typedefs in explicit instantiations.
* testsuite/27_io/basic_istringstream/cons/char/1.cc: Add more
tests for constructors.
* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_stringbuf/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 276badfd9657..437e2ba2a5f8 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -166,8 +166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#endif
#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
- using __sv_type = basic_string_view<char_type, traits_type>;
-
+ explicit
basic_stringbuf(const allocator_type& __a)
: basic_stringbuf(ios_base::in | std::ios_base::out, __a)
{ }
@@ -185,18 +184,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
{ _M_stringbuf_init(__mode); }
template<typename _SAlloc>
- basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
- const allocator_type& __a)
- : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a)
- { }
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ const allocator_type& __a)
+ : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a)
+ { }
template<typename _SAlloc>
- basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
- ios_base::openmode __mode,
- const allocator_type& __a)
- : __streambuf_type(), _M_mode(__mode),
- _M_string(static_cast<__sv_type>(__s), __a)
- { }
+ basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s,
+ ios_base::openmode __mode,
+ const allocator_type& __a)
+ : __streambuf_type(), _M_mode(__mode),
+ _M_string(__s.data(), __s.size(), __a)
+ { _M_stringbuf_init(__mode); }
template<typename _SAlloc>
explicit
@@ -258,9 +257,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
- __sv_type
+ basic_string_view<char_type, traits_type>
view() const noexcept
{
+ using __sv_type = basic_string_view<char_type, traits_type>;
+
if (this->pptr())
{
// The current egptr() may not be the actual string end.
@@ -598,9 +599,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
ios_base::openmode __mode,
const allocator_type& __a)
- : __istream_type(),
- _M_stringbuf(__string_type(__str.data(), __str.size()),
- __mode | ios_base::in, __a)
+ : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in, __a)
{ this->init(std::__addressof(_M_stringbuf)); }
template<typename _SAlloc>
@@ -796,9 +795,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
ios_base::openmode __mode,
const allocator_type& __a)
- : __ostream_type(),
- _M_stringbuf(__string_type(__str.data(), __str.size()),
- __mode | ios_base::out, __a)
+ : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out, __a)
{ this->init(std::__addressof(_M_stringbuf)); }
template<typename _SAlloc>
@@ -991,8 +988,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str,
ios_base::openmode __mode,
const allocator_type& __a)
- : __iostream_type(),
- _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a)
+ : __iostream_type(), _M_stringbuf(__str, __mode, __a)
{ this->init(std::__addressof(_M_stringbuf)); }
template<typename _SAlloc>
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
index 8c6840115c50..ada3eabac1f5 100644
--- a/libstdc++-v3/src/c++20/sstream-inst.cc
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -43,7 +43,7 @@ template basic_stringbuf<char>::basic_stringbuf(basic_stringbuf&&,
const allocator_type&);
template basic_stringbuf<char>::allocator_type
basic_stringbuf<char>::get_allocator() const noexcept;
-template basic_stringbuf<char>::__sv_type
+template string_view
basic_stringbuf<char>::view() const noexcept;
template basic_istringstream<char>::basic_istringstream(ios_base::openmode,
@@ -68,8 +68,6 @@ template string_view
basic_stringstream<char>::view() const noexcept;
#ifdef _GLIBCXX_USE_WCHAR_T
-using wsv_type = basic_string_view<wchar_t>;
-
template basic_stringbuf<wchar_t>::basic_stringbuf(const allocator_type&);
template basic_stringbuf<wchar_t>::basic_stringbuf(ios_base::openmode,
const allocator_type&);
@@ -80,7 +78,7 @@ template basic_stringbuf<wchar_t>::basic_stringbuf(basic_stringbuf&&,
template basic_stringbuf<wchar_t>::allocator_type
basic_stringbuf<wchar_t>::get_allocator() const noexcept;
-template basic_istringstream<wchar_t>::__stringbuf_type::__sv_type
+template wstring_view
basic_stringbuf<wchar_t>::view() const noexcept;
template basic_istringstream<wchar_t>::basic_istringstream(ios_base::openmode,
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
index 496aa6963e0b..6584b88193d3 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
@@ -33,7 +33,7 @@ test01()
std::istringstream stm(std::ios_base::in, a);
}
-auto const cstr = "This is a test";
+auto const cstr = "This is a test string";
void
test02()
@@ -75,11 +75,44 @@ test03()
}
}
+// A minimal allocator with no default constructor
+template<typename T>
+ struct NoDefaultCons : __gnu_test::SimpleAllocator<T>
+ {
+ using __gnu_test::SimpleAllocator<T>::SimpleAllocator;
+
+ NoDefaultCons() = delete;
+
+ NoDefaultCons(int) { }
+ };
+
+void
+test04()
+{
+ using sstream = std::basic_istringstream<char, std::char_traits<char>,
+ NoDefaultCons<char>>;
+
+ NoDefaultCons<char> a(1);
+ const std::string str(cstr);
+
+ sstream ss1(str, a);
+ VERIFY( ss1.str() == cstr );
+ VERIFY( ss1.get() == cstr[0] );
+
+ sstream ss2(str, std::ios::out, a);
+ VERIFY( ss2.str() == cstr );
+ VERIFY( ss2.get() == cstr[0] );
+
+ sstream ss3(std::string(str), std::ios::out, a);
+ VERIFY( ss3.str() == cstr );
+ VERIFY( ss3.get() == cstr[0] );
+}
+
int
main()
{
test01();
test02();
test03();
- return 0;
+ test04();
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
index cba69f80931a..885949caf002 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
@@ -33,7 +33,7 @@ test01()
std::ostringstream stm(std::ios_base::in, a);
}
-auto const cstr = "This is a test";
+auto const cstr = "This is a test string";
void
test02()
@@ -75,11 +75,45 @@ test03()
}
}
+// A minimal allocator with no default constructor
+template<typename T>
+ struct NoDefaultCons : __gnu_test::SimpleAllocator<T>
+ {
+ using __gnu_test::SimpleAllocator<T>::SimpleAllocator;
+
+ NoDefaultCons() = delete;
+
+ NoDefaultCons(int) { }
+ };
+
+void
+test04()
+{
+ using sstream = std::basic_ostringstream<char, std::char_traits<char>,
+ NoDefaultCons<char>>;
+
+ NoDefaultCons<char> a(1);
+ const std::string str(cstr);
+
+ sstream ss1(str, a);
+ VERIFY( ss1.str() == cstr );
+
+ sstream ss2(str, std::ios::in, a);
+ VERIFY( ss2.str() == cstr );
+ VERIFY( bool(ss2 << "That") );
+ VERIFY( ss2.str() == "That is a test string" );
+
+ sstream ss3(std::string(str), std::ios::ate, a);
+ VERIFY( ss3.str() == cstr );
+ VERIFY( bool(ss3 << "y thing") );
+ VERIFY( ss3.str() == "This is a test stringy thing" );
+}
+
int
main()
{
test01();
test02();
test03();
- return 0;
+ test04();
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/1.cc
index 0e9649798f88..bd17e6ddc9e3 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/1.cc
@@ -17,7 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+// C++03 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
#include <sstream>
#include <testsuite_hooks.h>
@@ -30,8 +30,41 @@ void test01()
VERIFY( sbuf.check_pointers() );
}
-int main()
+void test02()
+{
+ std::stringbuf sbuf;
+ VERIFY( sbuf.str().empty() );
+
+ std::stringbuf sbuf1(std::ios::in);
+ VERIFY( sbuf1.str().empty() );
+
+ const std::string str = "This is my boomstick!";
+
+ std::stringbuf sbuf2(str);
+ VERIFY( sbuf2.str() == str );
+
+ std::stringbuf sbuf3(str, std::ios::in);
+ VERIFY( sbuf3.str() == str );
+ VERIFY( sbuf3.sgetc() == str[0] );
+ VERIFY( sbuf3.sputc('X') == std::stringbuf::traits_type::eof() );
+
+ std::stringbuf sbuf4(str, std::ios::out);
+ VERIFY( sbuf4.str() == str );
+ VERIFY( sbuf4.sputc('Y') == 'Y' );
+ VERIFY( sbuf4.sgetc() == std::stringbuf::traits_type::eof() );
+
+#if __cplusplus >= 201103L
+ static_assert( ! std::is_convertible<std::ios::openmode, std::stringbuf>(),
+ "stringbuf(ios::openmode) is explicit");
+
+ static_assert( ! std::is_convertible<const std::string&, std::stringbuf>(),
+ "stringbuf(string, ios::openmode) is explicit");
+#endif
+}
+
+int main()
{
test01();
+ test02();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
index ce669358c850..c72ca5c7c84d 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons]
// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
@@ -26,13 +26,24 @@
#include <testsuite_allocator.h>
#include <testsuite_hooks.h>
+template<typename Alloc, typename C = typename Alloc::value_type>
+ using stringbuf_with_alloc
+ = std::basic_stringbuf<C, std::char_traits<C>, Alloc>;
+
void
test01()
{
+ // Test C++20 constructors taking an allocator but no string.
+
+ static_assert(!std::is_convertible_v<std::allocator<char>, std::stringbuf>,
+ "stringbuf(const allocator<char>&) is explicit");
+
{
using alloc_type = __gnu_test::uneq_allocator<char>;
- using sbuf_t = std::basic_stringbuf<char, std::char_traits<char>,
- alloc_type>;
+ using sbuf_t = stringbuf_with_alloc<alloc_type>;
+
+ static_assert(!std::is_convertible_v<const alloc_type&, sbuf_t>,
+ "basic_stringbuf(const basic_stringbuf::allocator_type&) is explicit");
alloc_type aa;
sbuf_t sbuf1(aa);
@@ -48,29 +59,64 @@ test01()
std::stringbuf::allocator_type a;
{
std::stringbuf sbuf(std::ios_base::in, a);
+ VERIFY( sbuf.str().empty() );
+
+ std::stringbuf sbuf2 = {std::ios_base::in, a}; // non-explicit ctor
}
{
std::stringbuf sbuf(a);
+ VERIFY( sbuf.str().empty() );
}
}
-auto const cstr = "This is a test";
+auto const cstr = "This is a test string";
void
test02()
{
+ // Test C++20 constructor taking an rvalue string
+
+ static_assert(!std::is_convertible_v<std::string, std::stringbuf>,
+ "stringbuf(string&&, ios::openmode) is explicit");
+
std::string s1(cstr);
- std::stringbuf sbuf(std::move(s1));
+ std::stringbuf sbuf1(std::move(s1));
VERIFY( s1.empty() );
+ VERIFY( sbuf1.str() == cstr );
+ VERIFY( sbuf1.sgetc() == cstr[0] );
std::string s2(cstr);
- VERIFY( sbuf.str() == s2 );
+ std::stringbuf sbuf2(std::move(s2), std::ios_base::in);
+ VERIFY( s2.empty() );
+ VERIFY( sbuf2.str() == cstr );
+ VERIFY( sbuf2.sgetc() == cstr[0] );
+ VERIFY( sbuf2.sputc('X') == std::stringbuf::traits_type::eof() );
+
+ std::string s3(cstr);
+ std::stringbuf sbuf3(std::move(s3), std::ios_base::out);
+ VERIFY( s3.empty() );
+ VERIFY( sbuf3.str() == cstr );
+ VERIFY( sbuf3.sputc('Y') == 'Y' );
+ VERIFY( sbuf3.sgetc() == std::stringbuf::traits_type::eof() );
}
+// A minimal allocator with no default constructor
+template<typename T>
+ struct NoDefaultCons : __gnu_test::SimpleAllocator<T>
+ {
+ using __gnu_test::SimpleAllocator<T>::SimpleAllocator;
+
+ NoDefaultCons() = delete;
+
+ NoDefaultCons(int) { }
+ };
+
void
test03()
{
+ // Test C++20 constructors taking strings using different allocators
+
using alloc_type = __gnu_test::tracker_allocator<char>;
using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>;
@@ -78,28 +124,92 @@ test03()
str_type s1(cstr);
{
+ // basic_stringbuf(const basic_string<char, traits_type, SAlloc>&,
+ // ios_base::openmode,
+ // const allocator_type&)
+
std::stringbuf::allocator_type a;
- std::stringbuf sbuf(s1, mode, a);
+ std::stringbuf sbuf = {s1, mode, a}; // ={} checks for non-explicit ctor
std::string s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::stringbuf sbuf2 = {std::move(s1), std::ios::in, a};
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc('X') == std::stringbuf::traits_type::eof() );
+
+ std::stringbuf sbuf3 = {std::move(s1), std::ios::out, a};
+ VERIFY( sbuf3.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf3.sputc('X') == 'X' );
+ VERIFY( sbuf3.sgetc() == std::stringbuf::traits_type::eof() );
}
{
+ // explicit
+ // basic_stringbuf(const basic_string<char, traits_type, SAlloc>&,
+ // ios_base::openmode)
+
std::stringbuf sbuf(s1, mode);
std::string s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::stringbuf sbuf2(std::move(s1), std::ios::in);
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc('X') == std::stringbuf::traits_type::eof() );
+
+ std::stringbuf sbuf3(std::move(s1), std::ios::out);
+ VERIFY( sbuf3.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf3.sputc('X') == 'X' );
+ VERIFY( sbuf3.sgetc() == std::stringbuf::traits_type::eof() );
}
{
+ // explicit
+ // basic_stringbuf(const basic_string<char, traits_type, SAlloc>&,
+ // ios_base::openmode = ios_base::in|ios_base::out)
+
+ static_assert( ! std::is_convertible_v<str_type, std::stringbuf>,
+ "stringbuf(const basic_string<char, traits_type, SAlloc>&, openmode)"
+ " is explicit");
+
std::stringbuf sbuf(s1);
std::string s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::stringbuf sbuf2(std::move(s1));
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ }
+
+ {
+ NoDefaultCons<char> a(1);
+ stringbuf_with_alloc<NoDefaultCons<char>> sbuf1(s1, a);
+ VERIFY( sbuf1.str() == cstr );
+ VERIFY( sbuf1.sgetc() == s1[0] );
+
+ stringbuf_with_alloc<NoDefaultCons<char>> sbuf2(s1, std::ios::in, a);
+ VERIFY( sbuf2.str() == cstr );
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc('X') == std::stringbuf::traits_type::eof() );
+
+ stringbuf_with_alloc<NoDefaultCons<char>> sbuf3(s1, std::ios::out, a);
+ VERIFY( sbuf3.str() == cstr );
+ VERIFY( sbuf3.sputc('X') == 'X' );
+ VERIFY( sbuf3.sgetc() == std::stringbuf::traits_type::eof() );
}
}
void
test04()
{
+ // Test C++20 allocator-extended move constructor
+
std::stringbuf sbuf1(cstr);
std::stringbuf::allocator_type a;
@@ -117,5 +227,4 @@ main()
test02();
test03();
test04();
- return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc
index 7d51744fd8d2..4e3a2a9631d8 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc
@@ -17,7 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+// C++03 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
#include <sstream>
#include <testsuite_hooks.h>
@@ -30,8 +30,41 @@ void test01()
VERIFY( sbuf.check_pointers() );
}
-int main()
+void test02()
+{
+ std::wstringbuf sbuf;
+ VERIFY( sbuf.str().empty() );
+
+ std::wstringbuf sbuf1(std::wios::in);
+ VERIFY( sbuf1.str().empty() );
+
+ const std::wstring str = L"This is my boomstick!";
+
+ std::wstringbuf sbuf2(str);
+ VERIFY( sbuf2.str() == str );
+
+ std::wstringbuf sbuf3(str, std::wios::in);
+ VERIFY( sbuf3.str() == str );
+ VERIFY( sbuf3.sgetc() == str[0] );
+ VERIFY( sbuf3.sputc(L'X') == std::wstringbuf::traits_type::eof() );
+
+ std::wstringbuf sbuf4(str, std::wios::out);
+ VERIFY( sbuf4.str() == str );
+ VERIFY( sbuf4.sputc(L'Y') == L'Y' );
+ VERIFY( sbuf4.sgetc() == std::wstringbuf::traits_type::eof() );
+
+#if __cplusplus >= 201103L
+ static_assert( ! std::is_convertible<std::wios::openmode, std::wstringbuf>(),
+ "wstringbuf(wios::openmode) is explicit");
+
+ static_assert( ! std::is_convertible<const std::wstring&, std::wstringbuf>(),
+ "wstringbuf(wstring, wios::openmode) is explicit");
+#endif
+}
+
+int main()
{
test01();
+ test02();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
index e05acc421659..4fbbbf39ad39 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons]
+// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons]
// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
@@ -26,35 +26,97 @@
#include <testsuite_allocator.h>
#include <testsuite_hooks.h>
+template<typename Alloc, typename C = typename Alloc::value_type>
+ using stringbuf_with_alloc
+ = std::basic_stringbuf<C, std::char_traits<C>, Alloc>;
+
void
test01()
{
+ // Test C++20 constructors taking an allocator but no string.
+
+ static_assert(!std::is_convertible_v<std::allocator<wchar_t>, std::wstringbuf>,
+ "wstringbuf(const allocator<wchar_t>&) is explicit");
+
+ {
+ using alloc_type = __gnu_test::uneq_allocator<wchar_t>;
+ using sbuf_t = stringbuf_with_alloc<alloc_type>;
+
+ static_assert(!std::is_convertible_v<const alloc_type&, sbuf_t>,
+ "basic_stringbuf(const basic_stringbuf::allocator_type&) is explicit");
+
+ alloc_type aa;
+ sbuf_t sbuf1(aa);
+ VERIFY( aa == sbuf1.get_allocator() );
+
+ alloc_type aaa(42);
+ sbuf_t sbuf2(aaa);
+ VERIFY( aaa == sbuf2.get_allocator() );
+
+ VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() );
+ }
+
std::wstringbuf::allocator_type a;
{
std::wstringbuf sbuf(std::ios_base::in, a);
+ VERIFY( sbuf.str().empty() );
+
+ std::wstringbuf sbuf2 = {std::ios_base::in, a}; // non-explicit ctor
}
{
std::wstringbuf sbuf(a);
+ VERIFY( sbuf.str().empty() );
}
}
-auto const cstr = L"This is a test";
+auto const cstr = L"This is a test string";
void
test02()
{
+ // Test C++20 constructor taking an rvalue string
+
+ static_assert(!std::is_convertible_v<std::wstring, std::wstringbuf>,
+ "wstringbuf(wstring&&, ios::openmode) is explicit");
+
std::wstring s1(cstr);
- std::wstringbuf sbuf(std::move(s1));
+ std::wstringbuf sbuf1(std::move(s1));
VERIFY( s1.empty() );
+ VERIFY( sbuf1.str() == cstr );
+ VERIFY( sbuf1.sgetc() == cstr[0] );
std::wstring s2(cstr);
- VERIFY( sbuf.str() == s2 );
+ std::wstringbuf sbuf2(std::move(s2), std::ios_base::in);
+ VERIFY( s2.empty() );
+ VERIFY( sbuf2.str() == cstr );
+ VERIFY( sbuf2.sgetc() == cstr[0] );
+ VERIFY( sbuf2.sputc(L'X') == std::wstringbuf::traits_type::eof() );
+
+ std::wstring s3(cstr);
+ std::wstringbuf sbuf3(std::move(s3), std::ios_base::out);
+ VERIFY( s3.empty() );
+ VERIFY( sbuf3.str() == cstr );
+ VERIFY( sbuf3.sputc(L'Y') == L'Y' );
+ VERIFY( sbuf3.sgetc() == std::wstringbuf::traits_type::eof() );
}
+// A minimal allocator with no default constructor
+template<typename T>
+ struct NoDefaultCons : __gnu_test::SimpleAllocator<T>
+ {
+ using __gnu_test::SimpleAllocator<T>::SimpleAllocator;
+
+ NoDefaultCons() = delete;
+
+ NoDefaultCons(int) { }
+ };
+
void
test03()
{
+ // Test C++20 constructors taking strings using different allocators
+
using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
@@ -62,28 +124,92 @@ test03()
str_type s1(cstr);
{
+ // basic_stringbuf(const basic_string<wchar_t, traits_type, SAlloc>&,
+ // ios_base::openmode,
+ // const allocator_type&)
+
std::wstringbuf::allocator_type a;
- std::wstringbuf sbuf(s1, mode, a);
+ std::wstringbuf sbuf = {s1, mode, a}; // ={} checks for non-explicit ctor
std::wstring s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::wstringbuf sbuf2 = {std::move(s1), std::ios::in, a};
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc(L'X') == std::wstringbuf::traits_type::eof() );
+
+ std::wstringbuf sbuf3 = {std::move(s1), std::ios::out, a};
+ VERIFY( sbuf3.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf3.sputc(L'X') == L'X' );
+ VERIFY( sbuf3.sgetc() == std::wstringbuf::traits_type::eof() );
}
{
+ // explicit
+ // basic_stringbuf(const basic_string<wchar_t, traits_type, SAlloc>&,
+ // ios_base::openmode)
+
std::wstringbuf sbuf(s1, mode);
std::wstring s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::wstringbuf sbuf2(std::move(s1), std::ios::in);
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc(L'X') == std::wstringbuf::traits_type::eof() );
+
+ std::wstringbuf sbuf3(std::move(s1), std::ios::out);
+ VERIFY( sbuf3.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf3.sputc(L'X') == L'X' );
+ VERIFY( sbuf3.sgetc() == std::wstringbuf::traits_type::eof() );
}
{
+ // explicit
+ // basic_stringbuf(const basic_string<wchar_t, traits_type, SAlloc>&,
+ // ios_base::openmode = ios_base::in|ios_base::out)
+
+ static_assert( ! std::is_convertible_v<str_type, std::wstringbuf>,
+ "wstringbuf(const basic_string<wchar_t, traits_type, SAlloc>&,"
+ " openmode) is explicit");
+
std::wstringbuf sbuf(s1);
std::wstring s2(cstr);
VERIFY( sbuf.str() == s2 );
+
+ std::wstringbuf sbuf2(std::move(s1));
+ VERIFY( sbuf2.str() == s2 );
+ VERIFY( s1 == cstr ); // did not move from std::move(s1)
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ }
+
+ {
+ NoDefaultCons<wchar_t> a(1);
+ stringbuf_with_alloc<NoDefaultCons<wchar_t>> sbuf1(s1, a);
+ VERIFY( sbuf1.str() == cstr );
+ VERIFY( sbuf1.sgetc() == s1[0] );
+
+ stringbuf_with_alloc<NoDefaultCons<wchar_t>> sbuf2(s1, std::ios::in, a);
+ VERIFY( sbuf2.str() == cstr );
+ VERIFY( sbuf2.sgetc() == s1[0] );
+ VERIFY( sbuf2.sputc(L'X') == std::wstringbuf::traits_type::eof() );
+
+ stringbuf_with_alloc<NoDefaultCons<wchar_t>> sbuf3(s1, std::ios::out, a);
+ VERIFY( sbuf3.str() == cstr );
+ VERIFY( sbuf3.sputc(L'X') == L'X' );
+ VERIFY( sbuf3.sgetc() == std::wstringbuf::traits_type::eof() );
}
}
void
test04()
{
+ // Test C++20 allocator-extended move constructor
+
std::wstringbuf sbuf1(cstr);
std::wstringbuf::allocator_type a;
@@ -101,5 +227,4 @@ main()
test02();
test03();
test04();
- return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
index 83a3374b3cdb..33f2953a6513 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
@@ -33,7 +33,7 @@ test01()
std::stringstream stm(std::ios_base::in, a);
}
-auto const cstr = "This is a test";
+auto const cstr = "This is a test string";
void
test02()
@@ -57,29 +57,64 @@ test03()
{
std::stringstream::allocator_type a;
- std::stringstream sbuf(s1, mode, a);
+ std::stringstream ss(s1, mode, a);
std::string s2(cstr);
- VERIFY( sbuf.str() == s2 );
+ VERIFY( ss.str() == s2 );
}
{
- std::stringstream sbuf(s1, mode);
+ std::stringstream ss(s1, mode);
std::string s2(cstr);
- VERIFY( sbuf.str() == s2 );
+ VERIFY( ss.str() == s2 );
}
{
- std::stringstream sbuf(s1);
+ std::stringstream ss(s1);
std::string s2(cstr);
- VERIFY( sbuf.str() == s2 );
+ VERIFY( ss.str() == s2 );
}
}
+// A minimal allocator with no default constructor
+template<typename T>
+ struct NoDefaultCons : __gnu_test::SimpleAllocator<T>
+ {
+ using __gnu_test::SimpleAllocator<T>::SimpleAllocator;
+
+ NoDefaultCons() = delete;
+
+ NoDefaultCons(int) { }
+ };
+
+void
+test04()
+{
+ using sstream = std::basic_stringstream<char, std::char_traits<char>,
+ NoDefaultCons<char>>;
+
+ NoDefaultCons<char> a(1);
+ const std::string str(cstr);
+
+ sstream ss1(str, a);
+ VERIFY( ss1.str() == cstr );
+ VERIFY( ss1.get() == cstr[0] );
+
+ sstream ss2(str, std::ios::in, a);
+ VERIFY( ss2.str() == cstr );
+ VERIFY( ss2.get() == cstr[0] );
+ VERIFY( !bool(ss2 << 1) );
+
+ sstream ss3(std::string(str), std::ios::out, a);
+ VERIFY( ss3.str() == cstr );
+ VERIFY( bool(ss3 << 1) );
+ VERIFY( ss3.get() == std::wstringbuf::traits_type::eof() );
+}
+
int
main()
{
test01();
test02();
test03();
- return 0;
+ test04();
}
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2020-11-05 13:33 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 16:55 [PATCH] libstdc++: Implement C++20 features for <sstream> Thomas Rodgers
2020-10-07 19:44 ` Jonathan Wakely
2020-10-07 21:53 ` Thomas Rodgers
2020-10-08 1:15 ` Thomas Rodgers
2020-10-08 16:30 ` Jonathan Wakely
2020-10-09 23:28 ` Thomas Rodgers
2020-10-13 16:46 ` Jonathan Wakely
2020-10-26 20:47 ` Thomas Rodgers
2020-10-26 21:09 ` Jonathan Wakely
2020-10-28 23:59 ` Jonathan Wakely
2020-10-29 1:30 ` Jonathan Wakely
2020-10-29 20:06 ` Rainer Orth
2020-10-29 21:41 ` Jonathan Wakely
2020-10-29 22:51 ` Jonathan Wakely
2020-10-30 12:39 ` Rainer Orth
2020-11-04 19:54 ` Stephan Bergmann
2020-11-04 20:43 ` Thomas Rodgers
2020-11-04 21:45 ` Jonathan Wakely
2020-11-04 23:41 ` Jonathan Wakely
2020-11-05 13:33 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).