aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-11-05 12:16:13 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-11-05 13:31:32 +0000
commit432258be4f2cf4f0970f106db319e3dbab4ab13d (patch)
tree1c1c9d60c27e86527efb1ebce7cea15358519af1 /libstdc++-v3/src
parentcbc3f0bcc0e6dba4be2873f7ed7b63de6f8fc524 (diff)
downloadgcc-432258be4f2cf4f0970f106db319e3dbab4ab13d.zip
gcc-432258be4f2cf4f0970f106db319e3dbab4ab13d.tar.gz
gcc-432258be4f2cf4f0970f106db319e3dbab4ab13d.tar.bz2
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.
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++20/sstream-inst.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc
index 8c68401..ada3eab 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,