Revert "[libc] Breakup freelist_malloc into separate files" (#119749)
[llvm-project.git] / libcxx / test / std / utilities / memory / util.smartptr / util.smartptr.shared / util.smartptr.shared.mod / reset.pass.cpp
blob0d175d40d7ff616eba318369675dc72aa4407ca7
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <memory>
11 // shared_ptr
13 // void reset();
15 #include <memory>
16 #include <cassert>
18 #include "test_macros.h"
20 struct B
22 static int count;
24 B() {++count;}
25 B(const B&) {++count;}
26 virtual ~B() {--count;}
29 int B::count = 0;
31 struct A
32 : public B
34 static int count;
36 A() {++count;}
37 A(const A& other) : B(other) {++count;}
38 ~A() {--count;}
41 int A::count = 0;
43 int main(int, char**)
46 std::shared_ptr<B> p(new B);
47 p.reset();
48 assert(A::count == 0);
49 assert(B::count == 0);
50 assert(p.use_count() == 0);
51 assert(p.get() == 0);
53 assert(A::count == 0);
55 std::shared_ptr<B> p;
56 p.reset();
57 assert(A::count == 0);
58 assert(B::count == 0);
59 assert(p.use_count() == 0);
60 assert(p.get() == 0);
62 assert(A::count == 0);
64 return 0;