1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // template<class Y> void reset(Y* p);
18 #include "reset_helper.h"
19 #include "test_macros.h"
26 B(const B
&) {++count
;}
27 virtual ~B() {--count
;}
38 A(const A
& other
) : B(other
) {++count
;}
44 struct Derived
: A
{};
46 static_assert( HasReset
<std::shared_ptr
<int>, int*>::value
, "");
47 static_assert( HasReset
<std::shared_ptr
<A
>, Derived
*>::value
, "");
48 static_assert(!HasReset
<std::shared_ptr
<A
>, int*>::value
, "");
50 #if TEST_STD_VER >= 17
51 static_assert( HasReset
<std::shared_ptr
<int[]>, int*>::value
, "");
52 static_assert(!HasReset
<std::shared_ptr
<int[]>, int(*)[]>::value
, "");
53 static_assert( HasReset
<std::shared_ptr
<int[5]>, int*>::value
, "");
54 static_assert(!HasReset
<std::shared_ptr
<int[5]>, int(*)[5]>::value
, "");
60 std::shared_ptr
<B
> p(new B
);
63 assert(A::count
== 1);
64 assert(B::count
== 1);
65 assert(p
.use_count() == 1);
66 assert(p
.get() == ptr
);
68 assert(A::count
== 0);
73 assert(A::count
== 1);
74 assert(B::count
== 1);
75 assert(p
.use_count() == 1);
76 assert(p
.get() == ptr
);
78 assert(A::count
== 0);
82 std::shared_ptr
<const A
[]> p
;
85 assert(A::count
== 8);
86 assert(p
.use_count() == 1);
87 assert(p
.get() == ptr
);
89 assert(A::count
== 0);