Skip to content

Commit

Permalink
[libcxx] Add compatible with constraint tests for some shared_ptr con…
Browse files Browse the repository at this point in the history
…structors.

Add shared_ptr tests where the element type and pointer type aren't 'convertible' but are 'compatible'.

Responding to a comment from D81414.

Differential Revision: https://reviews.llvm.org/D81532
  • Loading branch information
zoecarver committed Aug 1, 2020
1 parent bb13c34 commit 8697d6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Expand Up @@ -28,6 +28,9 @@ struct A

int A::count = 0;

struct Base { };
struct Derived : Base { };

int main(int, char**)
{
{
Expand All @@ -46,5 +49,11 @@ int main(int, char**)
assert(test_deleter<A>::count == 0);
assert(test_deleter<A>::dealloc_count == 1);

{
// Make sure that we can construct a shared_ptr where the element type and pointer type
// aren't "convertible" but are "compatible".
static_assert(!std::is_constructible<std::shared_ptr<Derived[4]>, Base[4], test_deleter<Derived[4]> >::value, "");
}

return 0;
}
Expand Up @@ -28,6 +28,8 @@ struct A

int A::count = 0;

struct Base { };
struct Derived : Base { };

int main(int, char**)
{
Expand Down Expand Up @@ -87,5 +89,13 @@ int main(int, char**)
assert(test_deleter<A>::dealloc_count == 1);
#endif

{
// Make sure that we can construct a shared_ptr where the element type and pointer type
// aren't "convertible" but are "compatible".
static_assert(!std::is_constructible<std::shared_ptr<Derived[4]>,
Base[4], test_deleter<Derived[4]>,
test_allocator<Derived[4]> >::value, "");
}

return 0;
}

0 comments on commit 8697d6c

Please sign in to comment.