[PATCH] libstdc++: Implement C++20 features for <sstream>
Thomas Rodgers
rodgert@appliantology.com
Mon Oct 26 20:47:33 GMT 2020
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
More information about the Gcc-patches
mailing list