]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Implement proposed resolution to LWG 3548
authorJonathan Wakely <jwakely@redhat.com>
Mon, 10 May 2021 19:46:38 +0000 (20:46 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 10 May 2021 20:10:33 +0000 (21:10 +0100)
commit5edc0c15f1667cc2a5deb664b25c007b35d259f6
tree8706dbce1d5b9ea547ba54e885d59fd25b76cb5c
parentf974b54b8a0c330e9dd2b43ebc940100d601df0f
libstdc++: Implement proposed resolution to LWG 3548

This has been tentatively approved by LWG. The deleter from a unique_ptr
can be moved into the shared_ptr (at least, since LWG 2802). This uses
std::forward<_Del>(__r.get_deleter()) not std::move(__r.get_deleter())
because we don't want to convert the deleter to an rvalue when _Del is
an lvalue reference type.

This also adds a missing is_move_constructible_v<D> constraint to the
shared_ptr(unique_ptr<Y, D>&&) constructor, which is inherited from the
shared_ptr(Y*, D) constructor due to the use of "equivalent to" in the
specified effects.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_base.h (__shared_count(unique_ptr&&)):
Initialize a non-reference deleter from an rvalue, as per LWG
3548.
(__shared_ptr::_UniqCompatible): Add missing constraint.
* testsuite/20_util/shared_ptr/cons/lwg3548.cc: New test.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: Check
constraints.
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/testsuite/20_util/shared_ptr/cons/lwg3548.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc