PR libstdc++/58265 add noexcept to basic_string::assign(basic_string&&)
PR libstdc++/58265 * include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI] (basic_string::assign(basic_string&&)): Add conditional noexcept depending on the allocator's is_always_equal property (LWG 2063). * testsuite/21_strings/basic_string/modifiers/assign/char/ move_assign.cc: Check for non-throwing exception specification. * testsuite/21_strings/basic_string/modifiers/assign/wchar_t/ move_assign.cc: Likewise. From-SVN: r262447
This commit is contained in:
parent
99d2293dbf
commit
30236791e0
4 changed files with 16 additions and 2 deletions
|
@ -1,5 +1,14 @@
|
|||
2018-07-05 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/58265
|
||||
* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
|
||||
(basic_string::assign(basic_string&&)): Add conditional noexcept
|
||||
depending on the allocator's is_always_equal property (LWG 2063).
|
||||
* testsuite/21_strings/basic_string/modifiers/assign/char/
|
||||
move_assign.cc: Check for non-throwing exception specification.
|
||||
* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/
|
||||
move_assign.cc: Likewise.
|
||||
|
||||
PR libstdc++/58265
|
||||
* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
|
||||
[_GLIBCXX_FULLY_DYNAMIC_STRING==0] (basic_string::basic_string()):
|
||||
|
|
|
@ -725,7 +725,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|||
* The contents of @a str are moved into this string (without copying).
|
||||
* @a str is a valid, but unspecified string.
|
||||
**/
|
||||
// PR 58265, this should be noexcept.
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2063. Contradictory requirements for string move assignment
|
||||
basic_string&
|
||||
|
@ -4275,9 +4274,9 @@ _GLIBCXX_END_NAMESPACE_CXX11
|
|||
* This function sets this string to the exact contents of @a __str.
|
||||
* @a __str is a valid, but unspecified string.
|
||||
*/
|
||||
// PR 58265, this should be noexcept.
|
||||
basic_string&
|
||||
assign(basic_string&& __str)
|
||||
noexcept(allocator_traits<_Alloc>::is_always_equal::value)
|
||||
{
|
||||
this->swap(__str);
|
||||
return *this;
|
||||
|
|
|
@ -32,6 +32,9 @@ void test01()
|
|||
a.push_back('1');
|
||||
b.assign(std::move(a));
|
||||
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
|
||||
|
||||
// True for std::allocator because is_always_equal, but not true in general:
|
||||
static_assert(noexcept(a.assign(std::move(b))), "lwg 2063");
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -32,6 +32,9 @@ void test01()
|
|||
a.push_back(L'1');
|
||||
b.assign(std::move(a));
|
||||
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
|
||||
|
||||
// True for std::allocator because is_always_equal, but not true in general:
|
||||
static_assert(noexcept(a.assign(std::move(b))), "lwg 2063");
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
Loading…
Add table
Reference in a new issue