This is an archive of the discontinued LLVM Phabricator instance.

[libc++] [test] Add tests for converting array types in shared_ptr.
ClosedPublic

Authored by var-const on Oct 18 2021, 6:43 PM.

Details

Summary

The only possible kind of a conversion in initialization of a shared
pointer to an array is a qualification conversion (i.e., adding
cv-qualifiers). This patch adds tests for converting from A[] to
const A[] to the following functions:

template<class Y> explicit shared_ptr(Y* p);

template<class Y> shared_ptr(const shared_ptr<Y>& r);
template<class Y> shared_ptr(shared_ptr<Y>&& r);

template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r);
template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);

template<class Y> void reset(Y* p);
template<class Y, class D> void reset(Y* p, D d);
template<class Y, class D, class A> void reset(Y* p, D d, A a);

Similar tests for converting functions that involve a weak_ptr should
be added once LWG issue 3001
is implemented.

Diff Detail

Event Timeline

var-const requested review of this revision.Oct 18 2021, 6:43 PM
var-const created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2021, 6:43 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Oct 19 2021, 10:01 AM

Awesome, thanks for adding these tests!

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
100

For lurkers: this was most likely an oversight in the original test, since we mean to test the move constructor, not the copy constructor. @var-const told me offline, cause I was puzzled.

This revision is now accepted and ready to land.Oct 19 2021, 10:01 AM