]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make move ctor noexcept for fully-dynamic string
authorJonathan Wakely <jwakely@redhat.com>
Fri, 30 Apr 2021 14:04:34 +0000 (15:04 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 1 Oct 2021 19:34:47 +0000 (20:34 +0100)
commit10b6d89baddd86139480ba902f491903fcb464a6
treeb94c73c23bcea0a8e47d84a4c0b940c372fbd083
parentce709ad3dc0ed5d7ea48a116311d4441225446f0
libstdc++: Make move ctor noexcept for fully-dynamic string

The move constructor for the "fully-dynamic" COW string is not noexcept,
because it allocates a new empty string rep for the moved-from string.
However, there is no need to do that, because the moved-from string does
not have to be left empty. Instead, implement move construction for the
fully-dynamic case as a reference count increment, so the string is
shared.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/cow_string.h [_GLIBCXX_FULLY_DYNAMIC_STRING]
(basic_string(basic_string&&)): Add noexcept and avoid
allocation, by sharing rep with the rvalue string.
libstdc++-v3/include/bits/cow_string.h