P0935R0 Eradicating unnecessarily explicit default constructors

This is the last remaining piece of P0935R0. This adds a default
constructor to each of the streambuf and stream types in <sstream> so
that default construction does not use the 'explicit' constructor that
has a single, defaulted argument.

	P0935R0 Eradicating unnecessarily explicit default constructors
	* config/abi/pre/gnu.ver: Tighten existing patterns and export new
	default constructor symbols.
	* include/std/sstream (basic_stringbuf, basic_istringstream)
	(basic_ostringstream, basic_stringstream): Remove default arguments
	from explicit constructors taking ios_base::openmode and add separate
	non-explicit default constructors.
	* testsuite/27_io/basic_istringstream/cons/default.cc: New.
	* testsuite/27_io/basic_ostringstream/cons/default.cc: New.
	* testsuite/27_io/basic_stringstream/cons/default.cc: New.
	* testsuite/27_io/basic_stringbuf/cons/char/default.cc: New.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/default.cc: New.

From-SVN: r262474
This commit is contained in:
Jonathan Wakely 2018-07-06 13:39:02 +01:00 committed by Jonathan Wakely
parent 8660e7908f
commit 97271bd88f
8 changed files with 269 additions and 11 deletions

View File

@ -1,5 +1,18 @@
2018-07-06 Jonathan Wakely <jwakely@redhat.com>
P0935R0 Eradicating unnecessarily explicit default constructors
* config/abi/pre/gnu.ver: Tighten existing patterns and export new
default constructor symbols.
* include/std/sstream (basic_stringbuf, basic_istringstream)
(basic_ostringstream, basic_stringstream): Remove default arguments
from explicit constructors taking ios_base::openmode and add separate
non-explicit default constructors.
* testsuite/27_io/basic_istringstream/cons/default.cc: New.
* testsuite/27_io/basic_ostringstream/cons/default.cc: New.
* testsuite/27_io/basic_stringstream/cons/default.cc: New.
* testsuite/27_io/basic_stringbuf/cons/char/default.cc: New.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/default.cc: New.
* include/std/variant (__accepted_index): Use void_t.
2018-07-05 Jonathan Wakely <jwakely@redhat.com>

View File

@ -1748,10 +1748,20 @@ GLIBCXX_3.4.21 {
_ZStplI[cw]St11char_traitsI[cw]ESaI[cw]EENSt7__cxx1112basic_stringIT_T0_T1_EE*;
# ABI-tagged stringstreams
_ZNSt7__cxx1115basic_stringbuf*;
_ZNSt7__cxx1118basic_stringstream*;
_ZNSt7__cxx1119basic_istringstream*;
_ZNSt7__cxx1119basic_ostringstream*;
# _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]*;
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]E[ORS]*;
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EED[012]Ev;
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]*__xfer_bufptrs*;
_ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE[a1346789]*;
# _ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]*;
_ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]E[ORS]*;
_ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EED[012]Ev;
_ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE[a34]*;
# _ZNSt7__cxx1119basic_istringstreamI[cw]St11char_traitsI[cw]*;
# _ZNSt7__cxx1119basic_ostringstreamI[cw]St11char_traitsI[cw]*;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]E[ORS]*;
_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__cxx1118basic_stringstream*;
_ZNKSt7__cxx1119basic_istringstream*;
@ -2021,6 +2031,14 @@ GLIBCXX_3.4.26 {
_ZNSt13runtime_errorC[12]EOS_;
_ZNSt13runtime_erroraSEOS_;
# Default constructors for stringstreams
_ZNSt15basic_stringbuf[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt18basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt19basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt7__cxx1115basic_stringbuf[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt7__cxx1119basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
} GLIBCXX_3.4.25;
# Symbols in the support library (libsupc++) have their own tag.

View File

@ -89,6 +89,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
public:
// Constructors:
/**
* @brief Starts with an empty string buffer.
*
* The default constructor initializes the parent class using its
* own default ctor.
*/
basic_stringbuf()
: __streambuf_type(), _M_mode(ios_base::in | ios_base::out), _M_string()
{ }
/**
* @brief Starts with an empty string buffer.
* @param __mode Whether the buffer can read, or write, or both.
@ -97,7 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* own default ctor.
*/
explicit
basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
basic_stringbuf(ios_base::openmode __mode)
: __streambuf_type(), _M_mode(__mode), _M_string()
{ }
@ -401,8 +412,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
public:
// Constructors:
/**
* @brief Default constructor starts with an empty string buffer.
*
* Initializes @c sb using @c in, and passes @c &sb to the base
* class initializer. Does not allocate any buffer.
*
* That's a lie. We initialize the base class with NULL, because the
* string class does its own memory management.
*/
basic_istringstream()
: __istream_type(), _M_stringbuf(ios_base::in)
{ this->init(&_M_stringbuf); }
/**
* @brief Starts with an empty string buffer.
* @param __mode Whether the buffer can read, or write, or both.
*
* @c ios_base::in is automatically included in @a __mode.
@ -414,7 +439,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* string class does its own memory management.
*/
explicit
basic_istringstream(ios_base::openmode __mode = ios_base::in)
basic_istringstream(ios_base::openmode __mode)
: __istream_type(), _M_stringbuf(__mode | ios_base::in)
{ this->init(&_M_stringbuf); }
@ -545,8 +570,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
public:
// Constructors/destructor:
/**
* @brief Default constructor starts with an empty string buffer.
*
* Initializes @c sb using @c mode|out, and passes @c &sb to the base
* class initializer. Does not allocate any buffer.
*
* That's a lie. We initialize the base class with NULL, because the
* string class does its own memory management.
*/
basic_ostringstream()
: __ostream_type(), _M_stringbuf(ios_base::out)
{ this->init(&_M_stringbuf); }
/**
* @brief Starts with an empty string buffer.
* @param __mode Whether the buffer can read, or write, or both.
*
* @c ios_base::out is automatically included in @a mode.
@ -558,7 +597,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* string class does its own memory management.
*/
explicit
basic_ostringstream(ios_base::openmode __mode = ios_base::out)
basic_ostringstream(ios_base::openmode __mode)
: __ostream_type(), _M_stringbuf(__mode | ios_base::out)
{ this->init(&_M_stringbuf); }
@ -689,19 +728,32 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
public:
// Constructors/destructors
/**
* @brief Default constructor starts with an empty string buffer.
*
* Initializes @c sb using the mode @c in|out, and passes @c &sb
* to the base class initializer. Does not allocate any buffer.
*
* That's a lie. We initialize the base class with NULL, because the
* string class does its own memory management.
*/
basic_stringstream()
: __iostream_type(), _M_stringbuf(ios_base::out | ios_base::in)
{ this->init(&_M_stringbuf); }
/**
* @brief Starts with an empty string buffer.
* @param __m Whether the buffer can read, or write, or both.
*
* Initializes @c sb using the mode from @c __m, and passes @c
* &sb to the base class initializer. Does not allocate any
* buffer.
* Initializes @c sb using the mode from @c __m, and passes @c &sb
* to the base class initializer. Does not allocate any buffer.
*
* That's a lie. We initialize the base class with NULL, because the
* string class does its own memory management.
*/
explicit
basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in)
basic_stringstream(ios_base::openmode __m)
: __iostream_type(), _M_stringbuf(__m)
{ this->init(&_M_stringbuf); }

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018 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++11 27.8.3.1 basic_istringstream constructors [istringstream.cons]
// { dg-do run { target c++11 } }
#include <sstream>
#include <testsuite_common_types.h>
void test01()
{
// P0935R0
__gnu_test::implicitly_default_constructible test;
test.operator()<std::istringstream>();
}
int main()
{
test01();
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018 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++11 27.8.4.1 basic_ostringstream constructors [ostringstream.cons]
// { dg-do run { target c++11 } }
#include <sstream>
#include <testsuite_common_types.h>
void test01()
{
// P0935R0
__gnu_test::implicitly_default_constructible test;
test.operator()<std::ostringstream>();
}
int main()
{
test01();
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018 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++11 27.8.2.1 basic_stringbuf constructors [stringbuf.cons]
// { dg-do run { target c++11 } }
#include <sstream>
#include <testsuite_common_types.h>
void test01()
{
// P0935R0
__gnu_test::implicitly_default_constructible test;
test.operator()<std::stringbuf>();
}
int main()
{
test01();
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018 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++11 27.8.2.1 basic_stringbuf constructors [stringbuf.cons]
// { dg-do run { target c++11 } }
#include <sstream>
#include <testsuite_common_types.h>
void test01()
{
// P0935R0
__gnu_test::implicitly_default_constructible test;
test.operator()<std::wstringbuf>();
}
int main()
{
test01();
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018 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++11 27.8.5.1 basic_stringstream constructors [stringstream.cons]
// { dg-do run { target c++11 } }
#include <sstream>
#include <testsuite_common_types.h>
void test01()
{
// P0935R0
__gnu_test::implicitly_default_constructible test;
test.operator()<std::stringstream>();
}
int main()
{
test01();
}