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()):
* 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&
* 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;
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()
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()