diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-03-14 14:51:19 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-03-14 14:51:19 +0000 |
commit | 4f83482f4682c397c61d5edf60e39975d704d44e (patch) | |
tree | c0330af42a7929961e5bf69a771eaf9e4b6b40e2 | |
parent | 9b74f93310e3c0ff495dd8fb15b547b28e9be506 (diff) | |
download | gcc-4f83482f4682c397c61d5edf60e39975d704d44e.zip gcc-4f83482f4682c397c61d5edf60e39975d704d44e.tar.gz gcc-4f83482f4682c397c61d5edf60e39975d704d44e.tar.bz2 |
PR libstdc++/79162 disambiguate assignment from string_view
PR libstdc++/79162
* include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI]
(basic_string<C,T,A>::operator=(basic_string_view<C,T>)): Replace
with a constrained template.
[!_GLIBCXX_USE_CXX11_ABI]
(basic_string<C,T,A>::operator=(basic_string_view<C,T>)): Likewise.
* testsuite/21_strings/basic_string/cons/char/79162.cc: New test.
* testsuite/21_strings/basic_string/cons/wchar_t/79162.cc: New test.
From-SVN: r246128
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 14 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/cons/char/79162.cc | 28 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/79162.cc | 28 |
4 files changed, 75 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 544d155..4d4b2c4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2017-03-14 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/79162 + * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] + (basic_string<C,T,A>::operator=(basic_string_view<C,T>)): Replace + with a constrained template. + [!_GLIBCXX_USE_CXX11_ABI] + (basic_string<C,T,A>::operator=(basic_string_view<C,T>)): Likewise. + * testsuite/21_strings/basic_string/cons/char/79162.cc: New test. + * testsuite/21_strings/basic_string/cons/wchar_t/79162.cc: New test. + 2017-03-13 Ville Voutilainen <ville.voutilainen@gmail.com> PR libstdc++/80034 diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 981ffc5..b6693c4 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -758,9 +758,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @brief Set value to string constructed from a string_view. * @param __sv A string_view. */ - basic_string& - operator=(__sv_type __sv) - { return this->assign(__sv); } + template<typename _Tp> + _If_sv<_Tp, basic_string&> + operator=(_Tp __sv) + { return this->assign(__sv); } /** * @brief Convert to a string_view. @@ -3560,9 +3561,10 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @brief Set value to string constructed from a string_view. * @param __sv A string_view. */ - basic_string& - operator=(__sv_type __sv) - { return this->assign(__sv); } + template<typename _Tp> + _If_sv<_Tp, basic_string&> + operator=(_Tp __sv) + { return this->assign(__sv); } /** * @brief Convert to a string_view. diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/79162.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/79162.cc new file mode 100644 index 0000000..0afbe11 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/79162.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2017 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-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } + +#include <string> + +void +test01() +{ + std::string s; + s = {"abc", 1}; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/79162.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/79162.cc new file mode 100644 index 0000000..0afbe11 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/79162.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2017 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-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } + +#include <string> + +void +test01() +{ + std::string s; + s = {"abc", 1}; +} |