PR libstdc++/58265 implement LWG 2063 for COW strings
authorJonathan Wakely <jwakely@redhat.com>
Thu, 5 Jul 2018 15:56:06 +0000 (16:56 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 5 Jul 2018 15:56:06 +0000 (16:56 +0100)
commitd8d9b83b33dd13d81a1e107ce4d1e075a30e6f21
tree0a88c59686cedaf90660aa6b1ff706abecd71692
parent245471c67f3ad27a85dce999933cec1ff298be02
PR libstdc++/58265 implement LWG 2063 for COW strings

For COW strings the default constructor does not allocate when
_GLIBCXX_FULLY_DYNAMIC_STRING == 0, so can be noexcept. The move
constructor and swap do not allocate when the allocators are equal, so
add conditional noexcept using allocator_traits::is_always_equal.

PR libstdc++/58265
* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
[_GLIBCXX_FULLY_DYNAMIC_STRING==0] (basic_string::basic_string()):
Add GLIBCXX_NOEXCEPT.
(basic_string::operator=(basic_string&&)): Add _GLIBCXX_NOEXCEPT_IF
to depend on the allocator's is_always_equal property (LWG 2063).
(basic_string::swap(basic_string&)): Likewise.
* include/bits/basic_string.tcc [!_GLIBCXX_USE_CXX11_ABI]
(basic_string::swap(basic_string&)): Likewise.
* testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
Check is_nothrow_move_assignable.
* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
Check is_nothrow_move_assignable.
* testsuite/21_strings/basic_string/cons/char/
noexcept_move_construct.cc: Likewise.
* testsuite/21_strings/basic_string/cons/wchar_t/
noexcept_move_construct.cc: Likewise.

From-SVN: r262443
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc
libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc