[PATCH] PR libstdc++/58265 implement LWG 2063 for COW strings

Jonathan Wakely jwakely@redhat.com
Thu Jul 5 17:01:00 GMT 2018


On 05/07/18 16:55 +0100, Jonathan Wakely wrote:
>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.

I missed a bit, finished by this patch. With these changes the SSO and
COW strings are slightly closer in behaviour, although the COW one is
still missing lots of C++11 features (like passing const_iterator
instead of iterator) and C++17 features (deduction guides).

Tested powerpc64le-linux, committed to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3158 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180705/39cee02c/attachment.bin>


More information about the Libstdc++ mailing list