libstdc++: Fix new <sstream> constructors
authorJonathan Wakely <jwakely@redhat.com>
Thu, 5 Nov 2020 12:16:13 +0000 (12:16 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 5 Nov 2020 13:31:32 +0000 (13:31 +0000)
commit432258be4f2cf4f0970f106db319e3dbab4ab13d
tree1c1c9d60c27e86527efb1ebce7cea15358519af1
parentcbc3f0bcc0e6dba4be2873f7ed7b63de6f8fc524
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.
libstdc++-v3/include/std/sstream
libstdc++-v3/src/c++20/sstream-inst.cc
libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/1.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc