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);
19 #include "reset_helper.h"
20 #include "test_macros.h"
27 B(const B
&) {++count
;}
28 virtual ~B() {--count
;}
39 A(const A
& other
) : B(other
) {++count
;}
45 struct Derived
: A
{};
47 static_assert( HasReset
<std::shared_ptr
<int>, int*>::value
, "");
48 static_assert( HasReset
<std::shared_ptr
<A
>, Derived
*>::value
, "");
49 static_assert(!HasReset
<std::shared_ptr
<A
>, int*>::value
, "");
51 #if TEST_STD_VER >= 17
52 static_assert( HasReset
<std::shared_ptr
<int[]>, int*>::value
, "");
53 static_assert(!HasReset
<std::shared_ptr
<int[]>, int(*)[]>::value
, "");
54 static_assert( HasReset
<std::shared_ptr
<int[5]>, int*>::value
, "");
55 static_assert(!HasReset
<std::shared_ptr
<int[5]>, int(*)[5]>::value
, "");
61 std::shared_ptr
<B
> p(new B
);
64 assert(A::count
== 1);
65 assert(B::count
== 1);
66 assert(p
.use_count() == 1);
67 assert(p
.get() == ptr
);
69 assert(A::count
== 0);
74 assert(A::count
== 1);
75 assert(B::count
== 1);
76 assert(p
.use_count() == 1);
77 assert(p
.get() == ptr
);
79 assert(A::count
== 0);
83 std::shared_ptr
<const A
[]> p
;
86 assert(A::count
== 8);
87 assert(p
.use_count() == 1);
88 assert(p
.get() == ptr
);
90 assert(A::count
== 0);