2018-05-03 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/84087 LWG DR 2268 basic_string default arguments
+ * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI=1]
+ (append(const basic_string&, size_type, size_type)
+ (assign(const basic_string&, size_type, size_type)
+ (insert(size_type, const basic_string&, size_type, size_type)
+ (replace(size_type,size_type,const basic_string&,size_type,size_type)
+ (compare(size_type,size_type,constbasic_string&,size_type,size_type)):
+ Add default arguments (LWG 2268).
+ [_GLIBCXX_USE_CXX11_ABI=0]
+ (append(const basic_string&, size_type, size_type)
+ (assign(const basic_string&, size_type, size_type)
+ (insert(size_type, const basic_string&, size_type, size_type)
+ (replace(size_type,size_type,const basic_string&,size_type,size_type)
+ (compare(size_type,size_type,constbasic_string&,size_type,size_type)):
+ Likewise.
+ * testsuite/21_strings/basic_string/dr2268.cc: New test.
+
PR libstdc++/84535
* include/std/thread (thread::__not_same): New SFINAE helper.
(thread::thread(_Callable&&, _Args&&...)): Add SFINAE constraint that
* remainder of @a __str is appended.
*/
basic_string&
- append(const basic_string& __str, size_type __pos, size_type __n)
+ append(const basic_string& __str, size_type __pos, size_type __n = npos)
{ return _M_append(__str._M_data()
+ __str._M_check(__pos, "basic_string::append"),
__str._M_limit(__pos, __n)); }
* __str, the remainder of @a __str is used.
*/
basic_string&
- assign(const basic_string& __str, size_type __pos, size_type __n)
+ assign(const basic_string& __str, size_type __pos, size_type __n = npos)
{ return _M_replace(size_type(0), this->size(), __str._M_data()
+ __str._M_check(__pos, "basic_string::assign"),
__str._M_limit(__pos, __n)); }
*/
basic_string&
insert(size_type __pos1, const basic_string& __str,
- size_type __pos2, size_type __n)
+ size_type __pos2, size_type __n = npos)
{ return this->replace(__pos1, size_type(0), __str._M_data()
+ __str._M_check(__pos2, "basic_string::insert"),
__str._M_limit(__pos2, __n)); }
*/
basic_string&
replace(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2)
+ size_type __pos2, size_type __n2 = npos)
{ return this->replace(__pos1, __n1, __str._M_data()
+ __str._M_check(__pos2, "basic_string::replace"),
__str._M_limit(__pos2, __n2)); }
*/
int
compare(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2) const;
+ size_type __pos2, size_type __n2 = npos) const;
/**
* @brief Compare to a C string.
* remainder of @a __str is appended.
*/
basic_string&
- append(const basic_string& __str, size_type __pos, size_type __n);
+ append(const basic_string& __str, size_type __pos, size_type __n = npos);
/**
* @brief Append a C substring.
* __str, the remainder of @a __str is used.
*/
basic_string&
- assign(const basic_string& __str, size_type __pos, size_type __n)
+ assign(const basic_string& __str, size_type __pos, size_type __n = npos)
{ return this->assign(__str._M_data()
+ __str._M_check(__pos, "basic_string::assign"),
__str._M_limit(__pos, __n)); }
*/
basic_string&
insert(size_type __pos1, const basic_string& __str,
- size_type __pos2, size_type __n)
+ size_type __pos2, size_type __n = npos)
{ return this->insert(__pos1, __str._M_data()
+ __str._M_check(__pos2, "basic_string::insert"),
__str._M_limit(__pos2, __n)); }
*/
basic_string&
replace(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2)
+ size_type __pos2, size_type __n2 = npos)
{ return this->replace(__pos1, __n1, __str._M_data()
+ __str._M_check(__pos2, "basic_string::replace"),
__str._M_limit(__pos2, __n2)); }
*/
int
compare(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2) const;
+ size_type __pos2, size_type __n2 = npos) const;
/**
* @brief Compare to a C string.
--- /dev/null
+// 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/>.
+
+// { dg-do run { target c++11 } }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ // PR libstdc++/84087
+
+ std::string s0 = "string";
+ std::string s;
+ s.append(s0, 2);
+ VERIFY( s == "ring" );
+ s.assign(s0, 3);
+ VERIFY( s == "ing" );
+ s.insert(2, s0, 4);
+ VERIFY( s == "inngg" );
+ s.replace(2, 3, s0, 2);
+ VERIFY( s == "inring" );
+ VERIFY( s.compare(2, 4, s0, 2) == 0 );
+}
+
+int
+main()
+{
+ test01();
+}