mirror of git://gcc.gnu.org/git/gcc.git
PR libstdc++/83511 add default argument to basic_string_view::substr
PR libstdc++/83511 * include/std/string_view (basic_string_view::substr): Add default argument to first parameter. * include/experimental/string_view (basic_string_view::substr): Likewise. * testsuite/21_strings/basic_string_view/operations/substr/char/ 83511.cc: New test. * testsuite/21_strings/basic_string_view/operations/substr/wchar_t/ 83511.cc: New test. * testsuite/experimental/string_view/operations/substr/char/83511.cc: New test. * testsuite/experimental/string_view/operations/substr/wchar_t/83511.cc: New test. From-SVN: r266568
This commit is contained in:
parent
188588e443
commit
0a1369fa95
|
|
@ -1,3 +1,19 @@
|
||||||
|
2018-11-28 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
PR libstdc++/83511
|
||||||
|
* include/std/string_view (basic_string_view::substr): Add default
|
||||||
|
argument to first parameter.
|
||||||
|
* include/experimental/string_view (basic_string_view::substr):
|
||||||
|
Likewise.
|
||||||
|
* testsuite/21_strings/basic_string_view/operations/substr/char/
|
||||||
|
83511.cc: New test.
|
||||||
|
* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/
|
||||||
|
83511.cc: New test.
|
||||||
|
* testsuite/experimental/string_view/operations/substr/char/83511.cc:
|
||||||
|
New test.
|
||||||
|
* testsuite/experimental/string_view/operations/substr/wchar_t/83511.cc:
|
||||||
|
New test.
|
||||||
|
|
||||||
2018-11-28 Edward Smith-Rowland <3dw4rd@verizon.net>
|
2018-11-28 Edward Smith-Rowland <3dw4rd@verizon.net>
|
||||||
|
|
||||||
Implement uniform container erasure for C++20.
|
Implement uniform container erasure for C++20.
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ inline namespace fundamentals_v1
|
||||||
// [string.view.ops], string operations:
|
// [string.view.ops], string operations:
|
||||||
|
|
||||||
constexpr basic_string_view
|
constexpr basic_string_view
|
||||||
substr(size_type __pos, size_type __n=npos) const
|
substr(size_type __pos = 0, size_type __n = npos) const
|
||||||
{
|
{
|
||||||
return __pos <= this->_M_len
|
return __pos <= this->_M_len
|
||||||
? basic_string_view{this->_M_str + __pos,
|
? basic_string_view{this->_M_str + __pos,
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr basic_string_view
|
constexpr basic_string_view
|
||||||
substr(size_type __pos, size_type __n = npos) const noexcept(false)
|
substr(size_type __pos = 0, size_type __n = npos) const noexcept(false)
|
||||||
{
|
{
|
||||||
__pos = _M_check(__pos, "basic_string_view::substr");
|
__pos = _M_check(__pos, "basic_string_view::substr");
|
||||||
const size_type __rlen = std::min(__n, _M_len - __pos);
|
const size_type __rlen = std::min(__n, _M_len - __pos);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// { dg-options "-std=gnu++17" }
|
||||||
|
// { dg-do run { target c++17 } }
|
||||||
|
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
// basic_string_view::substr
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
const std::string_view s = "abcdef";
|
||||||
|
VERIFY( s.substr() == s );
|
||||||
|
VERIFY( std::string_view{}.substr().empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// { dg-options "-std=gnu++17" }
|
||||||
|
// { dg-do run { target c++17 } }
|
||||||
|
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
// basic_string_view::substr
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
const std::wstring_view s = L"abcdef";
|
||||||
|
VERIFY( s.substr() == s );
|
||||||
|
VERIFY( std::wstring_view{}.substr().empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// { dg-do run { target c++14 } }
|
||||||
|
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
// experimental::basic_string_view::substr
|
||||||
|
|
||||||
|
#include <experimental/string_view>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
const std::experimental::string_view s = "abcdef";
|
||||||
|
VERIFY( s.substr() == s );
|
||||||
|
VERIFY( std::experimental::string_view{}.substr().empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// { dg-do run { target c++14 } }
|
||||||
|
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
// experimental::basic_string_view::substr
|
||||||
|
|
||||||
|
#include <experimental/string_view>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
const std::experimental::wstring_view s = L"abcdef";
|
||||||
|
VERIFY( s.substr() == s );
|
||||||
|
VERIFY( std::experimental::wstring_view{}.substr().empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue